I'm Michael Suodenjoki - a software engineer living in Kgs. Lyngby, north of Copenhagen, Denmark. This is my personal site containing my blog, photos, articles and main interests.

Updated 2011.01.23 15:37 +0100

 

Vista, Windows SDK and MFC

If your C++ application uses MFC you may receive compiler error when compiling with the Windows SDK (released November 2006) and targeting the Microsoft Vista platform by setting the NTDDI_VERSION define to NTDDI_LONGHORN (why they haven't used NTDDI_VISTA  beats me).

The error is:

WINVER not defined. Defaulting to 0x0502 (Windows Server 2003)
C:\Program Files\Microsoft SDKs\Windows\v6.0\Include\sdkddkver.h(213) : fatal error C1189: #error : NTDDI_VERSION setting conflicts with _WIN32_WINNT setting

This seems to be caused by some of the MFC headers (e.g. afxv_w32.h) still refer to the old legacy WINVER and _WIN32_WINNT defines. But if you use them instead of the NTDDI_VERSION until new MFC headers are released (probably with Visual Studio "Orcas") you can resolve the problem.

For many it have always been confusing to use one version of Visual Studio and another version of the Platform SDK (which is now renamed to Windows SDK). Also these two have been independently released over the years (and probably will in the future) spreading more confusion on what you're really compiling with.

For instance what version of the Standard C++ library are you really compiling with when having Visual Studio 2005 SP1 and the Microsoft SDK 6 (from Nov 2006) installed, since they both include the C++ headers? It of course depends on your PATH, INCLUDE and LIB environment variable settings but there are subtle differences between them. The file stamps on the Visual Studio 2005 SP1 files are a couple of months newer.

Background information about setting up target platform at MSDN.

Note: The Windows SDK does not come with MFC or ATL libraries anymore so these are only available from Visual Studio installs.