• Announcements

Archived

This topic is now archived and is closed to further replies.

struc dll_export ?

Recommended Posts

I know how to export a variable, a function and even a class... Now, I truied to export a struct but I just couldn't make it... where in the followed code do you place the __declspec(dllexport) :
  typedef struct { char name[128]; int age; } Person; [/source} Thanks, Amadrias Edited by - amadrias on January 12, 2002 3:45:35 PM 

Share on other sites
As far as I can tell, the problem is not that you (your code) are trying to export a struct, but trying to export a typedef, which are "internal" to the code, a bit like a macro substitution, just a renaming.

You can try dropping the typedef and use a plain struct declaration. The C++ standard states that you can use the struct''s ''tag'' (i.e. it''s name) without the struct keyword (which was the reason why people used the typedef trick), while C still requires it.

So people using your DLL in C code would have to write ''struct Person'' while people using C++ would write ''Person''. Alternatively they might themselve do a typedef, or you, yourself, provide it in a header file.

• Partner Spotlight

• Forum Statistics

• Total Topics
627682
• Total Posts
2978614

• 13
• 12
• 10
• 12
• 22