What is the D2 __declspec (dllexport) language equivalent
I have a link D2 DLL sample code . Exporting functions in both the dmd namespace and the standard C namespace works like a charm. But I come across uncharted waters regarding the sharing of the global int variable between DLLs, as well as the main exe program ... I checked the DLL symbol table with depend22_x86, and while I tried to use the export directive just before the Var declaration, it does not appear in the DLL table , and the functions are performed. Is it possible to export Varibles to be visible in a DLL using the Digital Mars dmd toolchain?
It was a bug in the compiler ( Bugzilla 10059 ). The following code should work now.
export __gshared int foo;
As a workaround, if exporting or importing global variables doesn't work, write a wrapper function of the form
Type variable; extern(C) Type * getGlobalVariable() { return &variable; }
if you want to export from D to C.
Maybe you can do what Ralph Tandecki says, but in the ctor static module. You do not have to explicitly call any function, all characters will be loaded. Maybe __gshared would be appreciated too.