I have a C++ project that references many other projects/libraries. This is for an application that was created many years ago. About every once a year it is updated and a new version is done. I've used Visual Studio 6 to update and build new versions of this app for years now without any problems.
I am trying to switch to Visual Studio 10 (and now VS2013). Initially I ran into several warnings and errors which were due to compatibility issues between the VS versions. I was able to take care of most. However, I'm still somewhat confused by the following error:
error C1189: #error : MFC does not support WINVER less than 0x0501. Please change the definition of WINVER in your project properties or precompiled header. C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\include\afxv_w32.h
The error occurs in a few of the referenced project libraries. I checked the project libraries in question and I cant find any reference to WINVER.
I have searched the internet for info on this and found some topics but nothing that is specific to my problem. Can someone shed some light as to what might be happening here?
Thanks in advance. LA
By default WINVER is defined as 0x0500 in preprocessor. To overcome from this error, remove defined win version "WINVER=0x0500" from Configuration Properties => c/c++ => Preprocessor tab and rebuild. Or you can provide higher WIN VERSION as #define _WIN32_WINNT 0x601 in your code wherever you getting error.
No, it's not "deprecated". At least not by anyone with the official status to deprecate it.
_WIN32_WINNT is a preprocessor token, which is replaced by (0x0601) wherever _WIN32_WINNT is used. The preprocessor just scans the whole file and replaces _WIN32_WINNT with (0x0601) everywhere it is found.
WINVER means Windows Version. In a nutshell, if you're building for a particular version of Windows, some APIs are available that are not available on previous versions.
All MFC apps define the WINVER
macro value somewhere if you didn't define it yourself. I assume MS has removed the definition by default on its own header files and is now making mandatory that you explicitly define it.
So, to solve your problem, either put the #define
in your 'preprocessor' compiler options, or at the top of your precompiled header (ie stdafx.h).
Note 0x501
is Windows XP support. 0x600
is Vista, 0x601
is Windows 7 — and how sad am I for remembering that!
I got the same error, on Windows 7 with Visual Studio 2013.
In my case my project had a source file with name stdafx.h
, inside that file there was
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
I changed it to
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x601
#endif
and the error disappeared.
By default WINVER is defined as 0x0500 in preprocessor. To overcome from this error, remove defined win version "WINVER=0x0500" from Configuration Properties => c/c++ => Preprocessor tab and rebuild.
Or you can provide higher WIN VERSION as #define _WIN32_WINNT 0x601 in your code wherever you getting error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With