VS2003转VS2010 fatal error C1189: #error

我本身的mfc的demo要转换编译环境出现如下编译错误:html

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

在google中找到解决办法,函数

_WIN32_WINNT这个宏对应定义的系统的版本号,若是过低的话,编译器就会认为代码没法在当前的系统上编译。ui

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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.
#endif

但编译后又出现如下问题:google

1> stdafx.cpp
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin.h(4024): error C2061: 语法错误: 标识符“PSCROLLBARINFO”
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2065: “PSCROLLBARINFO”: 未声明的标识符
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2146: 语法错误: 缺乏“)”(在标识符“pScrollInfo”的前面)
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2761: “BOOL CScrollBar::GetScrollBarInfo(void) const”: 不容许成员函数从新声明
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(184): error C2059: 语法错误:“)”
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(185): error C2143: 语法错误 : 缺乏“;”(在“{”的前面)
1>d:\program files\microsoft visual studio 10.0\vc\atlmfc\include\afxwin4.inl(185): error C2447: “{”: 缺乏函数标题(是不是老式的形式表?)

  比较郁闷。。。。spa

#ifndef WINVER				// 容许使用 Windows 95 和 Windows NT 4 或更高版本的特定功能。
//#define WINVER 0x0400		//为 Windows98 和 Windows 2000 及更新版本改变为适当的值。 刚刚此处没有修改
#define WINVER 0x0501	
#endif

  如今应该正常。.net

参考网友:code

http://www.cnblogs.com/madhenry/archive/2011/06/29/2093678.htmlhtm

http://blog.csdn.net/cs_21cn/article/details/7925455

相关文章
相关标签/搜索