export keyword messes up static linking
torhu
fake at address.dude
Thu Jan 25 22:27:15 PST 2007
I think I'll try to restate the problem in a simpler way.
I have a C lib, that I want to link with D apps. So I write a D
'header', like so:
module clib;
export extern extern (C) {
int foo;
char* bar;
}
This works just fine, if I link dynamically with the C lib. But if I
want to link statically, it doesn't work. This is because 'export'
can't be there when you link statically. foo and bar ptr get random
values in the D app.
In this example 'export' works like msvc's __declspec(dllimport). So in
C code, you could use a macro to turn it off for static linking.
Does Optlink have a switch for this, or can someone tell me how to write
a .def file so I don't have to declare the variables 'export'?
This C lib is cross-platform, so I'd also like to know if gcc (for dmd
use), or at least gdc has a solution for this. Currently we use a
script that just does 's/export//g'.
More information about the Digitalmars-d-learn
mailing list