_MSC_VER詳細介紹 _MSC_VER詳細介紹

_MSC_VER詳細介紹

轉自:http://www.cnblogs.com/braver/articles/2064817.htmlhtml

_MSC_VER是微軟的預編譯控制。post

_MSC_VER能夠分解爲:url

MS:Microsoft的簡寫。spa

C:MSC就是Microsoft的C編譯器。code

VER:Version的簡寫。htm

_MSC_VER的意思就是:Microsoft的C編譯器的版本。blog

微軟不一樣時期,編譯器有不一樣的版本:開發

MS VC++10.0 _MSC_VER=1600get

MS VC++9.0 _MSC_VER=1500編譯器

MS VC++8.0 _MSC_VER=1400

......

其中MS VC++10.0就是Visual C++ 2010,MS VC++9.0就是Visual C++2008,MS VC++8.0就是Visual C++2005

在程序中加入_MSC_VER宏能夠根據編譯器版本讓不一樣版本的編譯器選擇性地編譯一段程序。

查看編譯的版本信息,能夠在Command line裏敲 cl /?

 

文章二

_MSC_VER定義編譯器的版本。常見編譯器版本_MSC_VER值:

MSVC++ 11.0 _MSC_VER = 1700 (Visual Studio 2011) 
MSVC++ 10.0 _MSC_VER = 1600 (Visual Studio 2010) 
MSVC++ 9.0  _MSC_VER = 1500 (Visual Studio 2008) 
MSVC++ 8.0  _MSC_VER = 1400 (Visual Studio 2005) 
MSVC++ 7.1  _MSC_VER = 1310 (Visual Studio 2003) 
MSVC++ 7.0  _MSC_VER = 1300 
MSVC++ 6.0  _MSC_VER = 1200 
MSVC++ 5.0  _MSC_VER = 1100

 

在程序中加入_MSC_VER宏能夠根據編譯器版本讓編譯器選擇性地編譯一段程序。例如一個版本編譯器產生的lib文件可能不能被另外一個版本的編譯器調用,那麼在開發應用程序的時候,在該程序的lib調用庫中放入多個版本編譯器產生的lib文件。在程序中加入_MSC_VER宏,編譯器就可以在調用的時根據其版本自動選擇能夠連接的lib庫版本,以下所示。

 

 

 #if _MSC_VER >= 1400 // for vc8, or vc9 

  #ifdef _DEBUG 

  #pragma comment( lib, "SomeLib-vc8-d.lib" ) 

  #else if 

  #pragma comment( lib, "SomeLib-vc8-r.lib" ) 

  #endif 

  #else if _MSC_VER >= 1310 // for vc71 

  #ifdef _DEBUG 

  #pragma comment( lib, "SomeLib-vc71-d.lib" ) 

  #else if 

  #pragma comment( lib, "SomeLib-vc71-r.lib" ) 

  #endif 

  #else if _MSC_VER >=1200 // for vc6 

  #ifdef _DEBUG 

  #pragma comment( lib, "SomeLib-vc6-d.lib" ) 

  #else if 

  #pragma comment( lib, "SomeLib-vc6-r.lib" ) 

  #endif 

  #endif
相關文章
相關標籤/搜索