Interfacing with C++

2018-02-03 Thread infinityplusb via Digitalmars-d-learn
Hi all I'm looking to try and write an interface to C++, but given I'm a casual dabbler in D, it's slightly beyond my current ability in terms of both C++ and D! As a leg up, how would one translate something like this from C++ to D? `typedef int (CV_CDECL* CvCmpFunc)(const void* a, const

Re: Strange things allowed in iasm

2018-02-03 Thread Basile B. via Digitalmars-d-learn
On Sunday, 4 February 2018 at 05:45:02 UTC, Basile B. wrote: 1/ void foo() { asm pure nothrow { naked; mov RAX, [0x10][0x20] R8; ret; } } generates ;--- SUB 00449468h --- 00449468h mov eax, 0030h 0044946Dh ret

Strange things allowed in iasm

2018-02-03 Thread Basile B. via Digitalmars-d-learn
1/ void foo() { asm pure nothrow { naked; mov RAX, [0x10][0x20] R8; ret; } } generates ;--- SUB 00449468h --- 00449468h mov eax, 0030h 0044946Dh ret ;- 2/ void foo() { asm pure

Re: x86_64 iasm cannot directly load global variable with PIC code

2018-02-03 Thread Basile B. via Digitalmars-d-learn
On Sunday, 4 February 2018 at 05:03:31 UTC, Basile B. wrote: ``` __gshared a = "sdfg"; void main() { asm { mov RCX, [a]; } } ``` Error: cannot directly load global variable 'a' with PIC code How can i do that indirectly then ? Also consider that there's no RIP:

x86_64 iasm cannot directly load global variable with PIC code

2018-02-03 Thread Basile B. via Digitalmars-d-learn
``` __gshared a = "sdfg"; void main() { asm { mov RCX, [a]; } } ``` Error: cannot directly load global variable 'a' with PIC code How can i do that indirectly then ?

Re: DLangUI Drag and Drop support?

2018-02-03 Thread rikki cattermole via Digitalmars-d-learn
On 03/02/2018 6:06 PM, Andres Clari wrote: Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping URLs from the browser into a ListWidget. Is this possible with dlangui at all? No.

Re: Setting up DMD on windows

2018-02-03 Thread Seb via Digitalmars-d-learn
On Sunday, 4 February 2018 at 01:23:50 UTC, Rubn wrote: On Saturday, 3 February 2018 at 23:42:28 UTC, welkam wrote: [...] I think you have to build with an old version of MSVC, 2010 maybe? It's been a while since I built it I don't remember the exactly which version ended up working. 2013

Re: Setting up DMD on windows

2018-02-03 Thread Rubn via Digitalmars-d-learn
On Saturday, 3 February 2018 at 23:42:28 UTC, welkam wrote: Tried to use DMD compiler that I built from source by following these instructions https://wiki.dlang.org/Building_under_Windows They are outdated but I managed to compile it but I get this error when I tried to compile some code.

Setting up DMD on windows

2018-02-03 Thread welkam via Digitalmars-d-learn
Tried to use DMD compiler that I built from source by following these instructions https://wiki.dlang.org/Building_under_Windows They are outdated but I managed to compile it but I get this error when I tried to compile some code. dmdm -run Main.d

Array element Replace

2018-02-03 Thread Vino via Digitalmars-d-learn
Hi All, Request your help, on hot to replace an element(a[2]) in an array with the element(a[3]) Eg, auto a = Array!string("T1","T2","T3"); writeln(D1.replace(a[2], a[3])); From, Vino.B

Re: Adjacent item in a array

2018-02-03 Thread Vino via Digitalmars-d-learn
On Saturday, 3 February 2018 at 19:28:01 UTC, Seb wrote: On Saturday, 3 February 2018 at 19:13:05 UTC, Vino wrote: [...] 2.079 [1, 2] will ship with slide: --- auto arr = ["T1", "T2", "T3", "T4", "T5"]; arr.slide(2).each!writeln; --- [...] Hi Seb; Thank you very much. From, Vino.B

Re: BitArray shift left/right confusion.

2018-02-03 Thread Bastiaan Veelo via Digitalmars-d-learn
On Friday, 2 February 2018 at 00:33:03 UTC, Jakub Łabaj wrote: On the other hand, shifting operators are equally confusing for me, as they are for you - they really work in the other way around! I thought this is a very weird bug, but I found this pull request:

Re: Adjacent item in a array

2018-02-03 Thread Seb via Digitalmars-d-learn
On Saturday, 3 February 2018 at 19:13:05 UTC, Vino wrote: Hi All, Request you help on printing an array in below, Eg: Array ("T1", "T2", "T3", "T4", "T5") Output required as below T1,T2 T2,T3 T3,T4 T4,T5 From, Vino.B 2.079 [1, 2] will ship with slide: --- auto arr = ["T1", "T2", "T3",

Re: Adjacent item in a array

2018-02-03 Thread Vino via Digitalmars-d-learn
On Saturday, 3 February 2018 at 19:19:00 UTC, Adam D. Ruppe wrote: On Saturday, 3 February 2018 at 19:13:05 UTC, Vino wrote: Request you help on printing an array in below, Try looping through the array printing the current item followed by the item after the current item. Foreach with

Re: Adjacent item in a array

2018-02-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 3 February 2018 at 19:13:05 UTC, Vino wrote: Request you help on printing an array in below, Try looping through the array printing the current item followed by the item after the current item. Foreach with index may be helpful. Consider what happens on the last element.

Adjacent item in a array

2018-02-03 Thread Vino via Digitalmars-d-learn
Hi All, Request you help on printing an array in below, Eg: Array ("T1", "T2", "T3", "T4", "T5") Output required as below T1,T2 T2,T3 T3,T4 T4,T5 From, Vino.B

DLangUI Drag and Drop support?

2018-02-03 Thread Andres Clari via Digitalmars-d-learn
Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping URLs from the browser into a ListWidget. Is this possible with dlangui at all?

Can't cast from void*

2018-02-03 Thread Kagamin via Digitalmars-d-learn
--- interface A{} void* a=cast(void*)5; A b=cast(A)a; //ok A c=cast(A)cast(void*)5; //error --- Last line gives Error: cannot cast `void*` to `A`. Is it intended?

Re: sys_write in betterC doesn't write anything

2018-02-03 Thread Patrick Schluter via Digitalmars-d-learn
On Saturday, 3 February 2018 at 15:38:19 UTC, Basile B. wrote: On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote: [...] okay solved: module runnable; __gshared static msg = "betterC\n"; __gshared static len = 8; extern(C) int main(int argc, char** args) { asm {

Re: sys_write in betterC doesn't write anything

2018-02-03 Thread Basile B. via Digitalmars-d-learn
On Saturday, 3 February 2018 at 15:38:02 UTC, Adam D. Ruppe wrote: On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote: __gshared static msg = "betterC"; That's a D string mov ECX, msg ;//message to write And that's the address of a D string, instead of the address

Re: sys_write in betterC doesn't write anything

2018-02-03 Thread Basile B. via Digitalmars-d-learn
On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote: compiles with -betterC -m32 module runnable; __gshared static msg = "betterC"; __gshared static len = 7; extern(C) int main(int argc, char** args) { asm { naked; mov EDX, len ;//message length mov

Re: sys_write in betterC doesn't write anything

2018-02-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 3 February 2018 at 15:30:10 UTC, Basile B. wrote: __gshared static msg = "betterC"; That's a D string mov ECX, msg ;//message to write And that's the address of a D string, instead of the address of the characters. You need to put the pointer in there. So either

sys_write in betterC doesn't write anything

2018-02-03 Thread Basile B. via Digitalmars-d-learn
compiles with -betterC -m32 module runnable; __gshared static msg = "betterC"; __gshared static len = 7; extern(C) int main(int argc, char** args) { asm { naked; mov EDX, len ;//message length mov ECX, msg ;//message to write mov EBX, 1 ;//file

Re: Wiki spam

2018-02-03 Thread Vladimir Panteleev via Digitalmars-d-learn
On Saturday, 3 February 2018 at 06:34:57 UTC, Tony wrote: Don't know if there is a better place to report this, but the wiki attracted a spammer: Deleted, thanks. We're generally doing pretty well with spam (compared to other wikis) thanks to https://github.com/CyberShadow/dcaptcha , but