Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Export a variable from a DLL when compiling the D2 language with dmd?

Tags:

dll

d

dllexport

What is the D2 language equivalent of __declspec(dllexport)

I have the D2 DLL linkage example code up and running. Exporting functions, both in dmd's mangled name space as well as well as in standard u-mangled "C" name space, works like a charm. But I'm running into uncharted waters regarding the sharing of a (global) int Variable between DLL's as well as the main exe program... I've checked the DLL symbol table with depends22_x86 and while I made a point of using the export directive just before the Var's declaration, it does not show up in the DLL's table, while functions do. Can one export Varibles to be visible in a DLL with the Digital Mars dmd tool chain?

like image 414
Peter Li Avatar asked Jan 15 '12 10:01

Peter Li


1 Answers

This was a bug in the compiler (Bugzilla 10059). The following code should work now.

export __gshared int foo;
like image 186
Martin Nowak Avatar answered Oct 07 '22 18:10

Martin Nowak