www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - =?ISO-8859-1?Q?DLL_=80rror:_D_calling_D_extern(C)_code?=

reply Heinz <malagana15 yahoo.es> writes:
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?
Feb 10 2009
parent reply Heinz <malagana15 yahoo.es> writes:
Content-Type: text/plain

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".
Feb 10 2009
parent torhu <no spam.invalid> writes:
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;
Feb 11 2009