Heinz wrote:
torhu Wrote:

On 10.02.2009 19:51, Heinz wrote:
Heinz Wrote:

I attached a rar file with the sources just to see what i'm talking about. The example is from the 
DMD site. Included is the extern D (ok) and the extern C (fails). To compile open 
"compile.bat" and to run the programs use "run.bat".
Try this:
alias extern (C) void function(void*) MyDLL_Initialize_fp;
alias extern (C) void function() MyDLL_Terminate_fp;
alias extern (C) MyClass function() getMyClass_fp;

Haha! cool man, thanx, it works.
I never though it could be the type but adding extern(C), the program treats 
variables as C function pointers. I had no idea at all that i can create 
extern(C) variables to be trated as C type. I learned something new today!
Thanks again.


It doesn't affect normal variables. Calling a function through a function pointer, the calling convention still must be known in order for parameters to be properly passed. So any time you define a function pointer to point to a C function or to pass to a C API as a callback, it must have the proper extern linkage.

Reply via email to