Since intsafe.h
and stdint.h
both define INT8_MIN
. Thus VS2010 generate a warning that says :
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\stdint.h(72): warning C4005: 'INT8_MIN' : macro redefinition
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\intsafe.h(144) : see previous definition of 'INT8_MIN'
Is there a way to fix that warning in VS2010.
Once you've defined a macro, you can't redefine it to a different value without first removing the original definition. However, you can redefine the macro with exactly the same definition. Thus, the same definition may appear more than once in a program. The #undef directive removes the definition of a macro.
A macro is a piece of code in a program that is replaced by the value of the macro. Macro is defined by #define directive. Whenever a macro name is encountered by the compiler, it replaces the name with the definition of the macro.
Macros can be undefined from the command line using the /U option, followed by the macro names to be undefined.
The #define directive causes the compiler to substitute token-string for each occurrence of identifier in the source file. The identifier is replaced only when it forms a token. That is, identifier is not replaced if it appears in a comment, in a string, or as part of a longer identifier.
Apparently it's a bug in VS2010. You can avoid it in general but in MFC applications it's basically impossible to ever include stdint.h in any of your other code without hitting it.
I just did this at the top of the file that was complaining:
#pragma warning (push)
#pragma warning (disable : 4005)
#include <intsafe.h>
#include <stdint.h>
#pragma warning (pop)
It gets those headers 'out of the way' so to speak and lets you get on with your day.
In order simply to make the message go away, you can add the line
#pragma warning (disable : 4005)
before your first #include
statement
But that doesn't mean you shouldn't heed the warning. See if you can do without one of the two header files, and if not, be very certain of which definition your program is using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With