MFC 不支持 WINVER 小于 0x0501

2022-01-12 00:00:00 visual-studio mfc

我有一个 C++ 项目,它引用了许多其他项目/库.这是针对多年前创建的应用程序.大约每年更新一次,并完成一个新版本.多年来,我一直使用 Visual Studio 6 更新和构建这个应用程序的新版本,没有任何问题.

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.

我正在尝试切换到 Visual Studio 10(现在是 VS2013).最初,由于 VS 版本之间的兼容性问题,我遇到了几个警告和错误.我能够照顾大部分.但是,我仍然对以下错误感到有些困惑:

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 不支持小于 0x0501 的 WINVER.请在项目属性或预编译头文件中更改 WINVER 的定义.C:Program Files (x86)Microsoft Visual Studio 12.0VCatlmfcincludeafxv_w32.h

错误发生在一些引用的项目库中.我检查了有问题的项目库,但找不到对 WINVER 的任何引用.

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?

提前致谢.洛杉矶

推荐答案

如果您没有自己定义,所有 MFC 应用程序都会在某处定义 WINVER 宏值.我假设 MS 在其自己的头文件中默认删除了定义,现在强制您明确定义它.

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.

因此,要解决您的问题,请将 #define 放在您的预处理器"编译器选项中,或者放在预编译头文件(即 stdafx.h)的顶部.

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

注意 0x501 是 Windows XP 支持.0x600 是 Vista,0x601 是 Windows 7 ― 想起那件事我有多难过!

Note 0x501 is Windows XP support. 0x600 is Vista, 0x601 is Windows 7 ― and how sad am I for remembering that!

相关文章