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

前端 未结 11 1826
一生所求
一生所求 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:29

    Although this answer is for VS10, it's of interest as might provide some clues as to what's going on viz the VC++ directories macros: The warning appeared when these statements were added in the header file of a project, MyApp:

    #ifndef NTDDI_WINXPSP3
    #define NTDDI_WINXPSP3 0x05010300
    #endif 
    #ifndef NTDDI_VISTA
    #define NTDDI_VISTA 0x06000000
    #endif 
    #ifndef NTDDI_VISTASP1
    #define NTDDI_VISTASP1 0x06000100
    #endif 
    #ifndef NTDDI_WS08
    #define NTDDI_WS08 0x06000100
    #endif 
    

    Warnings like the following popped up for all but the XPSP3 def.:

    Warning RC4005: 'NTDDI_VISTASP1' : redefinition C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\sdkddkver.h.., MyApp

    MyApp was a WinDebug 32 build, noting Windows7.1SDK appeared in the X64 section of the proj file:

    
    Windows7.1SDK
    

    The inherited value for Preprocessor Definitions was _VC80_UPGRADE=0x0600. Having used the SDK toolset prior to reverting to V100, the SDK libraries were found as inherited_from in Include directories and Library Directories in the VC++ Directories section, as noted here.
    Looks like the warning is generated as a result of a combination of upgrading, migration, or toolset changes.

    Edit: An unrelated issue in VS2017 (MBCS) is opting to use

    LoadCursorW(nullptr, IDC_ARROW)
    

    instead of the default LoadCursorA(...) in a WNDCLASSEXW structure. A possible solution is to redefine like so:

     #define IDC_ARROW           MAKEINTRESOURCEW(32512)
    

    Here the warning can be suppressed by using the #undef procedure prior to the #define:

    #ifdef IDC_ARROW
    #undef IDC_ARROW
    #endif
    #define IDC_ARROW           MAKEINTRESOURCEW(32512)
    

提交回复
热议问题