日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

如何确定VS编译器版本--_MSC_VER || #if _MSC_VER 1000 #pragma once #endif

發布時間:2023/12/20 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 如何确定VS编译器版本--_MSC_VER || #if _MSC_VER 1000 #pragma once #endif 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如何確定VS編譯器版本

_MSC_VER是MSVC編譯器的內置宏,定義了編譯器的版本,_MSC_VER 值對應版本關系

MSVC++ 11.0 _MSC_VER = 1700 (Visual Studio 2012)??
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 (Visual Studio 2002)?
MSVC++ 6.0 _MSC_VER = 1200??
MSVC++ 5.0 _MSC_VER = 1100

?
example:

#if (_MSC_VER == 1300)? //vc7??(Visual Studio 2002)?
? ? #import "acax16ENU.tlb" no_implementation raw_interfaces_only named_guids
#elif (_MSC_VER == 1200)? //vc6
? ? #import "acad.tlb" no_implementation raw_interfaces_only named_guids
#elif (_MSC_VER == 1400) //vc8??(Visual Studio 2005) ?
? ? #import "acax17ENU.tlb" no_implementation raw_interfaces_only named_guids
#elif (_MSC_VER == 1500) //vc9 ?(Visual Studio 2008) ?
? ? #import "acax18ENU.tlb" no_implementation raw_interfaces_only named_guids
#endif


在程序中加入_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


==================================================================================================================

#if _MSC_VER > 1000

#pragma once

#endif

解釋:

這是微軟的預編譯控制。
在_MSC_VER較小時,它對一些東西的支持與新版不同


_MSC_VER分解如下:

MS:Microsoft(微軟)的簡寫

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

VER:Version(版本)的簡寫。

全部加在一起就是:Microsoft的C編譯器的版本


#pragma once???

指示這個文件在編譯時只被編譯器包括一次!一般用到.h中防止文件被重復包括!???


#if _MSC_VER > 1000?

是指如果vc編譯器的版本大于1000則這個語句被編譯!大概小于1000的版本不支持#pragma

once這個語句

?

很多頭文件中有

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

_MSC_VER 定義編譯器的版本,VC++6.0就是1200??
#if?? _MSC_VER?? >?? 1000的意思就是如果編譯器版本高于1000(VC++5.0)


總結

以上是生活随笔為你收集整理的如何确定VS编译器版本--_MSC_VER || #if _MSC_VER 1000 #pragma once #endif的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。