Archived

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

Amadrias

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites