Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2012 C++ warning C4005: '__useHeader': macro redefinition

While migrating an old C++ project from Visual Studio 6 up to Visual Studio 2012, we came across an odd set of warnings from inside the standard Microsoft platform headers:

  • warning C4005: '__useHeader' : macro redefinition
  • warning C4005: '__on_failure' : macro redefinition

An online search only found a few other people running into this error. In some cases, it was people trying to use VS2012 to compile legacy DirectX code - which I am not doing. In other cases, it was people trying to use VS2012 to target Windows XP (using the new option from Update 1) - which I am doing.

The DirectX question was answered that the warning will always be there to tell you that you're compiling with an out-of-date (pre-Win8) version of DirectX, and you'll just have to live with it.

The Windows XP question was not answered. Other people simply said that they couldn't reproduce the problem.

I reproduced it, and found the cause, which I am writing up here to help anybody else who encounters this.

like image 983
Jeff B Avatar asked Jan 16 '13 17:01

Jeff B


2 Answers

Go into the project properties, and find the "Preprocessor Definitions" field.

In addition to the default and added definition constants, you should see a macro:

%(PreprocessorDefinitions)

This macro apparently brings in some additional compiler-provided preprocessor definitions. I am not sure what version of Visual Studio introduced this macro, but it was not there in Visual Studio 6.

In Visual Studio 2012, this macro is required to be present in your project's Preprocessor Definitions field. It may also be required in earlier versions of Visual Studio, but I have not tested these.

If this macro is missing, you will see the error messages as shown above.

like image 184
Jeff B Avatar answered Oct 08 '22 19:10

Jeff B


UPDATE:

See Edmund's answer to this same question first -- give that a try. If it works, great! If not... try the following:

ORIGINAL:

Use the workaround mentioned on the "Workarounds" tab of this web page:

http://connect.microsoft.com/VisualStudio/feedback/details/789965/resource-editor-warning-rc4005-on-toolset-visual-studio-2012-windows-xp-v110-xp

Namely, add:

#define _USING_V110_SDK71_ 1

...directly in the .rc file before it includes anything that would include the system headers that cause this warning.

like image 23
DLRdave Avatar answered Oct 08 '22 20:10

DLRdave