S.Shil
S.Shil

Reputation: 89

Warning C4005 'identifier' : macro redefinition

I want my application to work in win32 and x64 platform. I have added below code in header file but I am getting C4005 warning. How can I avoid this?

#ifdef WIN32
#define SIZEOF_ANALYSIS_INFO 168    
#endif
#ifdef _WIN64
#define SIZEOF_ANALYSIS_INFO 172
#endif

Upvotes: 2

Views: 5865

Answers (1)

1201ProgramAlarm
1201ProgramAlarm

Reputation: 32732

The _WIN32 macro is always defined when compiling on Windows these days, even in 64 bit compiles. You'll want to rearrange your code a bit:

#ifdef _WIN64
#define SIZEOF_ANALYSIS_INFO 172
#elif defined(_WIN32)
#define SIZEOF_ANALYSIS_INFO 168
#endif

If you're always compiling this with VC, you can just use #else in the middle.

Better yet would to be to use the sizeof operator with whatever struct is holding the analysis info, if possible.

Upvotes: 3

Related Questions