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