Declaring a D pointer to a C function

Marco Cosentino cosentino.ma at gmail.com
Tue Jul 12 07:03:46 PDT 2011


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 the function pointer is a callback 
that gets called by a linked C library. IMHO I don't think that the 
alias definition should carry with her the informations about the 
calling convention. This is a convention for the caller and the callee.


More information about the Digitalmars-d-learn mailing list