struc dll_export ?

Started by
0 comments, last by Amadrias 22 years, 3 months ago
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  
Advertisement
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.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement