Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

visual studio 2012 - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...