c++windowswinapi

NTDDI_VERSION setting conflicts with _WIN32_WINNT setting


With VS2010 I have this error:

error C1189: #error : NTDDI_VERSION setting conflicts with _WIN32_WINNT setting

in StdAfx.h I use:

#define _WIN32_WINNT 0x0502 

and in my other source my.cpp I use:

#define NTDDI_VERSION 0x06000000 

How can I solve that?


Solution

  • #define NTDDI_VERSION 0x06000000 
    

    That is Vista.

    #define _WIN32_WINNT 0x0502 
    

    That is Server 2003.

    And so these versions are indeed conflicting. If you want to support Vista and up you'll need:

    #define NTDDI_VERSION 0x06000000 
    #define _WIN32_WINNT 0x0600 
    

    If you want Server 2003 and up then you use:

    #define NTDDI_VERSION 0x05020000
    #define _WIN32_WINNT 0x0502 
    

    Note that the NTDDI_VERSION define can also specify service packs. So if you want Vista SP1 and up then you use:

    #define NTDDI_VERSION 0x06000100 
    #define _WIN32_WINNT 0x0600 
    

    As a general rule you want to set these defines to the value corresponding to the minimum version that you wish to support.

    Rather than using these magic constants, you should write, for example:

    #define NTDDI_VERSION NTDDI_VISTA 
    #define _WIN32_WINNT _WIN32_WINNT_VISTA 
    

    For more details refer to: Using the Windows Headers.