Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

BeschBesch d475502 at drdrb.com
Sun Mar 30 04:16:14 PDT 2014


> have you looked at exported symbols in dll? it may be C++ from 
> what you said(lib not designed for C++?), so you can try 
> extern(C++) on D side instead extern(C). or add manually #ifdef 
> __cplusplus and extern "C" on lib side(if its not that big of 
> course).

First of all: I started with a C++-dll and tried to declare the 
functions with extern (C++) --> did not work. Then I switched the 
compiler to C. As VC++ still uses only C89 as standard you can 
imagine there is NOTHING C++-ish that could have survived. I also 
tested this DLL in a C++-application (static) and it worked like 
a charm.

ALSO:
> As i suspected that some things written by me could be 
> responsible for this, I build a test application with three 
> functions (Test, Test2,Test3), got myself the D-.lib for 
> statical-linking (implib-Dmd) and tried that one out. The 
> result: Error 42.

So, actually I am trying to get a DLL containing three 
single-line test functions to work. What I have already achieved 
is to load it dynamically, and it worked 
(Derelict.Util.Loader.SharedLibLoader Class). As I also use the 
Derelict-packages, I may intend to build a custom loader class as 
a work-around.


More information about the Digitalmars-d-learn mailing list