So I have a DLL+LIB exporting this:
extern "C" {
extern DLLPROJECT_API int myIntValue;
DLLPROJECT_API int myIntFunc(int a, int b);
}
In my D app I'm declaring it this way:
extern (C) {
extern __gshared int myIntValue;
int myIntFunc (int a, int b);
}
The function seems to link OK, but the C global will not.
Combinations I've tried:
- dmd 32-bit, linked against a coffimplib'ed lib file. This links
both successfully BUT myIntValue is trashed. myIntFunc does work
properly however.
- dmd m32mscoff, linking against native VS2017 lib. Complains
about variable but not the function.
- dmd m64, linking against native VS2017 lib. Complains about the
variable but not the function.
- ldc2 64-bit, linking against native VS2017 lib. Complains about
the variable but not the function.
I've examined the .DLL directly and the exported name
"myIntValue" looks exactly like what dmd/ldc2 are complaining
they cannot find.
What's the magic recipe here to get this variable linked (and not
gibberish)?