Thread overview
DLL €rror: D calling D extern(C) code
Feb 10, 2009
Heinz
Example Attached
Feb 10, 2009
Heinz
Feb 11, 2009
torhu
February 10, 2009
Hello everyone.
I've been using DLL's in D for a long time but just recently i'm having a problem. Lets see if someone can help me a bit.

I have several lines of code but i'll use an example from the DMD site wich is almost the same come.

Read the DMD site about DLL's here: http://www.digitalmars.com/d/1.0/dll.html

Check for the section "D code calling D code in DLLs".

If you extern(C) all exports in mydll.d and change all symbols in test.d to their C respectives, when running you'll get access violation.

Any ideas?
February 10, 2009
Heinz Wrote:

> Hello everyone.
> I've been using DLL's in D for a long time but just recently i'm having a problem. Lets see if someone can help me a bit.
> 
> I have several lines of code but i'll use an example from the DMD site wich is almost the same come.
> 
> Read the DMD site about DLL's here: http://www.digitalmars.com/d/1.0/dll.html
> 
> Check for the section "D code calling D code in DLLs".
> 
> If you extern(C) all exports in mydll.d and change all symbols in test.d to their C respectives, when running you'll get access violation.
> 
> Any ideas?

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".


February 11, 2009
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;