This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended

While building a product originally written with Visual Studio 6 on my machine (Windows 7 and Visual Studio 2010), I got for a few sub-projects the following error message:

c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlcore.h(35): fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended.

Using findstr, I could see that _WIN32_WINNT was not set in those projects. So the solution was easy. I just had to add the following to the beginning of stdafx.h in those projects:

#ifndef WINVER				// Allow use of features specific to Windows XP or later.
#define WINVER 0x0501		// Change this to the appropriate value to target other versions of Windows.
#endif

#ifndef _WIN32_WINNT		// Allow use of features specific to Windows XP or later.                   
#define _WIN32_WINNT 0x0501	// Change this to the appropriate value to target other versions of Windows.
#endif

After that the projects could build successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *