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

前端 未结 11 1819
一生所求
一生所求 2020-12-15 16:55

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:<

相关标签:
11条回答
  • 2020-12-15 17:45

    Haven't found a solution to this published anywhere online, so here's what worked for me.

    I'm building a project with 110_xp tools

    I get these warnings ...

    c:\program files (x86)\microsoft sdks\windows\v7.1a\include\sal_supp.h(57): warning C4005: '__useHeader' : macro redefinition
              C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2872) : see previous definition of '__useHeader'
    c:\program files (x86)\microsoft sdks\windows\v7.1a\include\specstrings_supp.h(77): warning C4005: '__on_failure' : macro redefinition
              C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\sal.h(2882) : see previous definition of '__on_failure'
    

    Clearly an inconsistency between the VC 11 headers and 7.1a sdk headers.

    In my stdafx.cpp I did this ...

    #define _USING_V110_SDK71_
    
    #include "stdafx.h"
    

    ... the build problem has gone away.

    0 讨论(0)
  • 2020-12-15 17:46

    I know this is old question, but... "sometimes they come back" :)

    Faced same warnings after install VS 2012 Express at fresh OS. After some investigation i decided to compare my current Program Files (x86)\Microsoft Visual Studio 11.0\VC\include folder with the same folder with VS 2012 Update 4. Here is comparison result:

    And sal.h diffs:

    So simple copying __useHeader's checks fixed all warnings.

    0 讨论(0)
  • 2020-12-15 17:48

    Adding #define _USING_V110_SDK71_ in Stdafx.cpp or Stdafx.h would not work if your cpp files do not have precompiled headers.

    To solve this problem, the following works.

    Right-click project in Solution Explorer* → PropertiesC/C++PreprocessorPreprocessor definitionedit → Add _USING_V110_SDK71_

    0 讨论(0)
  • 2020-12-15 17:54

    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.

    0 讨论(0)
  • 2020-12-15 17:54

    For me this happened with Visual Studio 2017 (both fresh and repaired installation). Obviously the Windows 7.1 SDK had been installed before VS2017 and had been integrated into a Visual Studio 2005 installation.

    In my case the two files:

    • %LOCALAPPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props
    • %LOCALAPPDATA%\Microsoft\MSBuild\v4.0\Microsoft.Cpp.x64.user.props

    contained references to the include directories and libraries of the Windows 7.1 SDK. Removing these references did the job.

    Keep in mind that every single C++ project for Win32 and x64 respectively inherits from these property sheets.

    0 讨论(0)
提交回复
热议问题