Valhalla Legends Forums Archive | C/C++ Programming | Macros

AuthorMessageTime
shout
Confused!

[code]
#ifdef STUFF_EXPORTS
#define STUFF_API __declspec(dllexport)
#else
#define STUFF_API __declspec(dllimport)
#endif

#ifdef STUFF_EXPORTS
#define STUFF_C_API __declspec(dllexport) extern "C"
#else
#define STUFF_C_API __declspec(dllimport) extern "C"
#endif
[/code]

Now lets say I have function n:
[code]
STUFF_C_API DWORD n(void *N);
[/code]
That wraps:
[code]
class STUFF_API Cn
{
...
}
[/code]
It gives me syntax errors. However, the following works.
[code]
__declspec(dllexport) extern "C" DWORD n(void *N);

class __declspec(dllexport) Cn
{
...
}
[/code]
The STUFF_EXPORTS is defined.

The compilers shitfits:
error C2146: syntax error : missing ';' before identifier 'DWORD'
error C2501: 'STUFF_C_API' : missing storage-class or type specifiers
error C2146: syntax error : missing ';' before identifier 'DWORD'
September 9, 2005, 7:11 PM
R.a.B.B.i.T
Seeing as how DWORD isn't used in any of the code you showed...well...I hope you get my drift.
September 9, 2005, 10:35 PM
shout
[quote author=rabbit link=topic=12754.msg127593#msg127593 date=1126305353]
Seeing as how DWORD isn't used in any of the code you showed...well...I hope you get my drift.
[/quote]

I ment to put DWORD before the n()
September 10, 2005, 4:16 AM
R.a.B.B.i.T
If I'm remembering last year correctly, the defines of STUFF_C_API won't include the "extern "C"".
September 10, 2005, 10:14 PM
Kp
Post the preprocessor output.  It'll be easier to debug that than to try to guess what your preprocessor is doing.
September 11, 2005, 1:30 AM
shout
I forgot to include the header file the macro was in :/.
September 13, 2005, 7:09 PM

Search