Re: Declaring a D pointer to a C function

2011-07-13 Thread Steven Schveighoffer
On Wed, 13 Jul 2011 11:32:50 -0400, Daniel Murphy wrote: "Andrej Mitrovic" wrote in message news:mailman.1607.1310570915.14074.digitalmars-d-le...@puremagic.com... Thanks! I've literally lost an entire day once when I was just starting using D and C together and had a calling convention mis

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1607.1310570915.14074.digitalmars-d-le...@puremagic.com... > Thanks! I've literally lost an entire day once when I was just > starting using D and C together and had a calling convention mismatch. > :x It's worse than just calling conventions - try

Re: Declaring a D pointer to a C function

2011-07-13 Thread Andrej Mitrovic
On 7/13/11, Daniel Murphy wrote: > "Andrej Mitrovic" wrote in message > news:mailman.1569.1310506439.14074.digitalmars-d-le...@puremagic.com... >> Is this going to be fixed any time soon? Allowing callbacks with D >> calling convention where a C callback is expected should be an error, >> and thi

Re: Declaring a D pointer to a C function

2011-07-13 Thread Daniel Murphy
"Andrej Mitrovic" wrote in message news:mailman.1569.1310506439.14074.digitalmars-d-le...@puremagic.com... > Is this going to be fixed any time soon? Allowing callbacks with D > calling convention where a C callback is expected should be an error, > and this is like the 10th time I've ran into th

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
Oh there's a pull already, this is great. https://github.com/D-Programming-Language/dmd/pull/96

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
On 7/12/11, Trass3r wrote: >> Is this going to be fixed any time soon? Allowing callbacks with D >> calling convention where a C callback is expected should be an error, >> and this is like the 10th time I've ran into this bug. > > http://d.puremagic.com/issues/show_bug.cgi?id=3797 > Thanks, I'm v

Re: Declaring a D pointer to a C function

2011-07-12 Thread Trass3r
Is this going to be fixed any time soon? Allowing callbacks with D calling convention where a C callback is expected should be an error, and this is like the 10th time I've ran into this bug. http://d.puremagic.com/issues/show_bug.cgi?id=3797

Re: Declaring a D pointer to a C function

2011-07-12 Thread Andrej Mitrovic
I just had a bug where a D function is implicitly converted to an extern(C) function pointer. I've had this definition: alias extern (C) void function(void* userData) PaStreamFinishedCallback; And this extern(C) function: PaError Pa_SetStreamFinishedCallback(PaStream* stream, PaStreamFinishedCal

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:53:28 -0400, Steven Schveighoffer wrote: But wait, don't normal D functions have C calling convention? I thought that was one of the benefits of D's ABI? Tested it out, definitely is different. So this clearly needs to be addressed. -Steve

Re: Declaring a D pointer to a C function

2011-07-12 Thread Marco Cosentino
On 12/07/2011 13:15, Trass3r wrote: You should declare the function pointer without the "extern(C)". Example: alias int function(void* test) FTInitFunc; extern(C) int foo(void* test){ } FTInitFunc foo_ptr = &foo; This worked for me. That's a bug. Oh, well, I forgot to mention that th

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 09:42:22 -0400, Johannes Pfau wrote: Steven Schveighoffer wrote: On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(vo

Re: Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
Trass3r wrote: >> You should declare the function pointer without the "extern(C)". >> >> Example: >> alias int function(void* test) FTInitFunc; >> >> extern(C) int foo(void* test){ } >> >> FTInitFunc foo_ptr = &foo; >> >> This worked for me. > >That's a bug. I agree. It looks like the above c

Re: Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
Steven Schveighoffer wrote: >On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau >wrote: > >> From a discussion related to derelict: >> How do you write this: >> --- >> alias extern(C) int function(void* test) FTInitFunc; >> FTInitFunc FT_Init_Free

Re: Declaring a D pointer to a C function

2011-07-12 Thread Steven Schveighoffer
On Tue, 12 Jul 2011 05:36:15 -0400, Johannes Pfau wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType ---

Re: Declaring a D pointer to a C function

2011-07-12 Thread Trass3r
You should declare the function pointer without the "extern(C)". Example: alias int function(void* test) FTInitFunc; extern(C) int foo(void* test){ } FTInitFunc foo_ptr = &foo; This worked for me. That's a bug.

Re: Declaring a D pointer to a C function

2011-07-12 Thread Marco Cosentino
On 12/07/2011 11:36, Johannes Pfau wrote: From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType ---

Declaring a D pointer to a C function

2011-07-12 Thread Johannes Pfau
From a discussion related to derelict: How do you write this: --- alias extern(C) int function(void* test) FTInitFunc; FTInitFunc FT_Init_FreeType --- without the alias? -