Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MFC does not support WINVER less than 0x0501

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

like image 813
user3242337 Avatar asked Jan 21 '15 21:01

user3242337


People also ask

How do I edit Winver in project properties?

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.

Is MFC obsolete?

No, it's not "deprecated". At least not by anyone with the official status to deprecate it.

What is _WIN32_WINNT?

_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.

How do you define Winver?

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.


3 Answers

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!

like image 65
gbjbaanb Avatar answered Sep 22 '22 02:09

gbjbaanb


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.

like image 42
Alessandro Jacopson Avatar answered Sep 21 '22 02:09

Alessandro Jacopson


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.

like image 26
Yogesh Dangre Avatar answered Sep 19 '22 02:09

Yogesh Dangre