VS2010遇到_WIN32_WINNT宏定义问题
2013-12-26 10:44
197 查看
最近拿到一个别人的工程,是使用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这个宏对应定义的系统的版本号,如果太低的话,编译器就会认为代码无法在当前的系统上编译。
在Project Property –> Configuration Properties–> C/C++ -> Command Line的Additional Options框中输入:
/D“_WIN32_WINNT=0×0501”
如果操作系统是Windows server 2003,则上述0×0501处改为0×0502;若为Windows 7,则为0×0601。
The following table describes the preferred macros in use by the Windows header files.
Minimum system required Macros to define Windows Server 2008 NTDDI_VERSION >= NTDDI_LONGHORN Windows Vista NTDDI_VERSION >= NTDDI_VISTA Windows Server 2003 SP1 NTDDI_VERSION >= NTDDI_WS03SP1 Windows Server 2003 NTDDI_VERSION >= NTDDI_WS03 Windows XP SP2 NTDDI_VERSION >= NTDDI_WINXPSP2 Windows XP SP1 NTDDI_VERSION >= NTDDI_WINXPSP1 Windows XP NTDDI_VERSION >= NTDDI_WINXP Windows 2000 SP4 NTDDI_VERSION >= NTDDI_WIN2KSP4 Windows 2000 SP3 NTDDI_VERSION >= NTDDI_WIN2KSP3 Windows 2000 SP2 NTDDI_VERSION >= NTDDI_WIN2KSP2 Windows 2000 SP1 NTDDI_VERSION >= NTDDI_WIN2KSP1 Windows 2000 NTDDI_VERSION >= NTDDI_WIN2K
The following table describes the legacy macros in use by the Windows header files.
Minimum system required Macros to define Windows Server 2008 _WIN32_WINNT>=0x0600 WINVER>=0x0600 Windows Vista _WIN32_WINNT>=0x0600 WINVER>=0x0600 Windows Server 2003 _WIN32_WINNT>=0x0502 WINVER>=0x0502 Windows XP _WIN32_WINNT>=0x0501 WINVER>=0x0501 Windows 2000 _WIN32_WINNT>=0x0500 WINVER>=0x0500 Windows NT 4.0 _WIN32_WINNT>=0x0400 WINVER>=0x0400 Windows Me _WIN32_WINDOWS=0x0500 WINVER>=0x0500 Windows 98 _WIN32_WINDOWS>=0x0410 WINVER>=0x0410 Windows 95 _WIN32_WINDOWS>=0x0400 WINVER>=0x0400 Internet Explorer 7.0 _WIN32_IE>=0x0700 Internet Explorer 6.0 SP2 _WIN32_IE>=0x0603 Internet Explorer 6.0 SP1 _WIN32_IE>=0x0601 Internet Explorer 6.0 _WIN32_IE>=0x0600 Internet Explorer 5.5 _WIN32_IE>=0x0550 Internet Explorer 5.01 _WIN32_IE>=0x0501 Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE>=0x0500 Internet Explorer 4.01 _WIN32_IE>=0x0401 Internet Explorer 4.0 _WIN32_IE>=0x0400 Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE>=0x0300
转完后果不其然真出了问题,在重新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这个宏对应定义的系统的版本号,如果太低的话,编译器就会认为代码无法在当前的系统上编译。
在Project Property –> Configuration Properties–> C/C++ -> Command Line的Additional Options框中输入:
/D“_WIN32_WINNT=0×0501”
如果操作系统是Windows server 2003,则上述0×0501处改为0×0502;若为Windows 7,则为0×0601。
The following table describes the preferred macros in use by the Windows header files.
Minimum system required Macros to define Windows Server 2008 NTDDI_VERSION >= NTDDI_LONGHORN Windows Vista NTDDI_VERSION >= NTDDI_VISTA Windows Server 2003 SP1 NTDDI_VERSION >= NTDDI_WS03SP1 Windows Server 2003 NTDDI_VERSION >= NTDDI_WS03 Windows XP SP2 NTDDI_VERSION >= NTDDI_WINXPSP2 Windows XP SP1 NTDDI_VERSION >= NTDDI_WINXPSP1 Windows XP NTDDI_VERSION >= NTDDI_WINXP Windows 2000 SP4 NTDDI_VERSION >= NTDDI_WIN2KSP4 Windows 2000 SP3 NTDDI_VERSION >= NTDDI_WIN2KSP3 Windows 2000 SP2 NTDDI_VERSION >= NTDDI_WIN2KSP2 Windows 2000 SP1 NTDDI_VERSION >= NTDDI_WIN2KSP1 Windows 2000 NTDDI_VERSION >= NTDDI_WIN2K
The following table describes the legacy macros in use by the Windows header files.
Minimum system required Macros to define Windows Server 2008 _WIN32_WINNT>=0x0600 WINVER>=0x0600 Windows Vista _WIN32_WINNT>=0x0600 WINVER>=0x0600 Windows Server 2003 _WIN32_WINNT>=0x0502 WINVER>=0x0502 Windows XP _WIN32_WINNT>=0x0501 WINVER>=0x0501 Windows 2000 _WIN32_WINNT>=0x0500 WINVER>=0x0500 Windows NT 4.0 _WIN32_WINNT>=0x0400 WINVER>=0x0400 Windows Me _WIN32_WINDOWS=0x0500 WINVER>=0x0500 Windows 98 _WIN32_WINDOWS>=0x0410 WINVER>=0x0410 Windows 95 _WIN32_WINDOWS>=0x0400 WINVER>=0x0400 Internet Explorer 7.0 _WIN32_IE>=0x0700 Internet Explorer 6.0 SP2 _WIN32_IE>=0x0603 Internet Explorer 6.0 SP1 _WIN32_IE>=0x0601 Internet Explorer 6.0 _WIN32_IE>=0x0600 Internet Explorer 5.5 _WIN32_IE>=0x0550 Internet Explorer 5.01 _WIN32_IE>=0x0501 Internet Explorer 5.0, 5.0a, 5.0b _WIN32_IE>=0x0500 Internet Explorer 4.01 _WIN32_IE>=0x0401 Internet Explorer 4.0 _WIN32_IE>=0x0400 Internet Explorer 3.0, 3.01, 3.02 _WIN32_IE>=0x0300
相关文章推荐
- VS2010中遇到 _WIN32_WINNT not defined
- VS2013+Cmake便于g2o遇到问题:error MSB3073: 命令“setlocal D:\tools\cmake-3.6.0-rc3-win32-x86\bin\cmake.exe -D
- 解决VS 2010调用OpenGL时遇到的问题
- 在64位机子调用vs编写的win32 c++程序遇到问题
- 解决VS 2010调用OpenGL时遇到的问题:error LNK2019
- c#学习中关于vs 2010遇到的中文注释,解决方案管理等器问题
- VS2010遇到_WIN32_WINNT宏定义问题
- vs2010报表遇到的问题
- VS2010中遇到_WIN32_WINNT not defined
- VS2010中生成遇到的 web.config 问题
- windows7下 VS2015 编译VLFeat所遇到的问题
- VS集成opencv编译C++项目遇到的问题
- VS2012 编译libmseed源码生成dll文件并调用中遇到的一些问题
- Generic host process for win32 services 遇到问题需要关闭!
- VS 2010下 打开实例 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏的问题
- VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x
- 今天遇到一个WIN32下的异步IO问题
- vs2013 创建C#控制台程序遇到的问题
- VS2015中使用Git遇到问题 Cannot do push / pull in git - working with visual studio
- VS2013配置QT5.6.2过程及其遇到的问题