optlink and weak symbols

Jacob Carlborg doob at me.com
Tue Oct 16 23:16:28 PDT 2012


On 2012-10-17 07:07, Ellery Newcomer wrote:
> I am interfacing with some C code [python.dll], which has some structs
> declared like so:
>
> PyTypeObject PyType_Type;
>
> I wish to be able to link to PyType_Type like so:
>
> extern(C) __gshared PyTypeObject PyType_Type;
>
> in linux, I can do exactly that, but optlink is generating a new memory
> location for PyType_Type.
>
> strings output suggests that my lib file contains the symbol PyType_Type.
>
> Is this sort of thing supposed to work?

You need to declare the variable as "extern" if it's defined in the C code:

extern(C) extern __gshared PyTypeObject PyType_Type;

http://dlang.org/interfaceToC.html#C%20Globals

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list