VS2010编译错: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403...的解决方法


最近拿到一个别人的工程,是使用VS.net创建的,而我的机器上只有vs2010,于是用自带的转换工具将它转换成vs2010的工程,转换之前我就很担心,怕转换完后会出问题,但是没有办法,我实在是不想再安一个vs.net了。

转完后果不其然真出了问题,在重新build工程时,报了一大堆错误,其中第一个就是“fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403. Value 0x0501 or higher is recommended”,然后看错误的来源,竟然是atlcore.h,这我就无语了,这是mfc自带的文件,出错的可能性基本上为0,于是只好去请教谷大叔,发现很多人都遇到了这个问题,看了几篇博客和帖子后,大概明白了,应该是_WIN32_WINNT这个宏对应定义的系统的版本号,如果太低的话,编译器就会认为代码无法在当前的系统上编译。

说了原因,下面是修改方法,就是在stdafx.h文件中修改相关的定义,修改完后的效果应该如下:

 

#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.

#define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.

#endif

#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.

#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.

#endif

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.

#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.

#endif

#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.

#define _WIN32_IE 0x0601 // Change this to the appropriate value to target IE 5.0 or later.

#endi

时间: 2024-08-05 07:28:20

VS2010编译错: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403...的解决方法的相关文章

fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0500. Val

fatal error C1189: #error :  This file requires _WIN32_WINNT to be#defined at least to 0x0500. Value 0x0501 or higher is recommended. VS2003的工程转换成VS2010后编译报错. 定位到afxcomctl32.h文件,这是系统文件没有做任何更改,主要还是版本兼容性问题. 修改方法: 新建一个targetver.h头文件,复制以下代码: #pragma once

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

VS2005转换成VS2010时出现的问题: 解决方法:打开stdafx.h文件修改如下: 注释掉: //#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.//#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or lat

安装centos6.10时,安装完成重启报错error 15,file not found

今天在一台老式联想服务器上安装centos6.10操作系统,安装完成,重启时,出现报错 error 15, file not found...... 在百度上搜索到进grub编辑,可还是无法解决问题,仍然file not found: 后来我将服务器硬盘格式化了,然后再正常安装系统,结果就能正常启动了,稀里糊涂的就解决了: 到现在还有疑惑,如果有哪位大神路过请解释一下,感激不尽 原文地址:https://www.cnblogs.com/new-journey/p/12039017.html

Vue报错:Uncaught TypeError: Cannot assign to read only property 'exports' of object 的解决方法

问题是这样的:如下>> 解决办法: 1“:我的webpack 最高版本,造成 混用import和module.exports :所以降低webpack版本 安装指定版本:npm install [email protected] -g 例如:npm install [email protected] -g 删除 编译目录文件: 2重新生成 然后输入启动命令: 成功解决!效果: 方法二: 注释掉后一个 重新生成,启动项目 OK! Vue报错:Uncaught TypeError: Cannot

【Error】Python:UnicodeDecodeError: ‘XXX' codec can't decode bytes in position... 解决方法

错误信息: UnicodeDecodeError: 'XXX' codec can't decode bytes in position 2-5: illegal multibyte sequence 这是因为遇到了非法字符,因此在转码的过程中出现了异常.具体哪些字符是非法字符我也搞不清. [解决办法] #将获取的字符串strTxt做decode时,指明ignore,会忽略非法字符,这样就可以了 inStr2 = inStr.decode('utf-8', 'ignore') [补充] 默认的参

2015.5.21 VS2010中引用Word组件后提示 类型“Microsoft.Office.Interop.Word.ApplicationClass”未定义构造函数 解决方法

wordApp = new Word.ApplicationClass();//这句在VS2005中没问题,在2010中会报错. 解决方法:在资源管理器 "引用"项的"Microsoft.Office.Interop.Word" 上点击鼠标右键,选择"属性",将属性中的"嵌入互操作类型"的值改为"false"即可.  这项在vs2005中没有

大数据调错系列之hadoop在开发工具控制台上打印不出日志的解决方法

(1)在windows环境上配置HADOOP_HOME环境变量 (2)在eclipse上运行程序 (3)注意:如果eclipse打印不出日志,在控制台上只显示 1.log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell). 2.log4j:WARN Please initialize the log4j system properly. 3.log4j:WARN See http://logg

MySQL设置外键报错 #1452 - Cannot add or update a child row: a foreign key constraint fails 解决方法

MySQL数据库,当我尝试在A表中设置B表的主键为外键时,报出错误:#1452 - Cannot add or update a child row: a foreign key constraint fails  于是去搜索了一下 "#1452 - Cannot add or update a child row: a foreign key constraint fails" 的含义与解决方法,根据这篇博文去排查了报错原因,排除了可能1和可能2,然后去研究可能3的具体含义,一开始并

Keil编译出现“Error: L6406W: No space in execution regions with .ANY selector match Section"的解决办法

情景: 在编译Keil工程时,compile编译能够通过,但在linking过程中,出现一大串"Error: L6406W: No space in execution regions with .ANY selector match Section"的错误. 分析: 这个出现的原因是因为芯片RAM空间不足,无法执行程序.通常RAM的空间会比较小,ROM空间相对较大. 解决办法: 两个思路,一个是扩大RAM,二是减少需要存在RAM里的内容: 1. 尝试修改"Target Op