21

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

user3242337
  • 253
  • 1
  • 2
  • 5
  • If you use a `stdafx.h`, you can add `#define WINVER 0x0501` to the top of that file. – wimh Jan 21 '15 at 21:51

4 Answers4

34

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!

sergiol
  • 4,122
  • 4
  • 47
  • 81
gbjbaanb
  • 51,617
  • 12
  • 104
  • 148
  • 7
    I had a similar problem, and no amount of `#define` fixed it. Turns out, in Visual Studio 2013, if you right click on your project, select properties, then in the options `Configuration Properties -> C/C++ -> All Options`, there was a `/DWINVER` there. – thejinx0r Mar 04 '15 at 03:43
  • @thejinx0r That can apply to all versions of VS, setting defines in the compiler options is nothing new, just see any makefile. – gbjbaanb Mar 04 '15 at 08:36
  • @gibnab I completely agree with your statement. I just wanted to mention that the `#define`s are sometimes buried in the options somewhere that you didn't expect. Furthermore, `#define WINVER`s in the code was not raising any redefinition errors – thejinx0r Mar 05 '15 at 20:24
  • @thejinx0r There is no such option in VS2017. But you can still do this by adding like "/DWINVER=0x0603" into Configuration Properties -> C/C++ ->Command Line->Additional Options – jw_ Sep 17 '19 at 01:55
14

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.

Alessandro Jacopson
  • 18,047
  • 15
  • 98
  • 153
4

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.

Yogesh Dangre
  • 181
  • 1
  • 4
0

What fixed for me was adding /D_WIN32_WINNT=0x0601 -DWINVER=_WIN32_WINNT in

Project properties -> C/C++ -> All Options -> Additional Options