Qs about structs and their references WRT C functions and variables

Rick Mann rmann-d-lang at latencyzero.com
Wed Jan 31 10:00:34 PST 2007


torhu Wrote:

> Try this:
> 
> extern extern (C) const HIViewID kHIViewWindowContentID;
> 
> http://www.digitalmars.com/d/declaration.html#extern
> 
> You need to add 'extern', just like in C headers.  Then 
> kHIViewWindowContentID will be a pure declaration, and the linker will 
> look elsewhere for a definition.  'extern (C)' by itself only causes the 
> compiler to output the symbol with C instead of D name mangling.

Thank you! That worked very well. I did not interpret that section to mean I needed to add a second "extern" keyword.
 
> If you link dynamically with the C lib, you are supposed to to add 
> 'export' too, even if it works without that in some cases.

"export" just before the rest of it, I suppose?

Can you tell me how "export" changes things? It's working right now without it, and I don't see where it is in the spec...



More information about the Digitalmars-d-learn mailing list