vsバージョンと_MSC_VERの対応

3266 ワード

同級生は質問をしたが,問題の原因が分からなかった.多角的に資料を探した後、プログラムが使用するライブラリと開発環境バージョンの問題であることが分かった.
プログラムvs 2010でコンパイル中にエラーが発生しました.
  	1	error C1189: #error :  "Wrong Compiler. This library does only run with Visual C++ 7.1 and Visual C++ 6. Newer versions are currently not supported."
このファイルを開きます.コードの一部は次のとおりです.
#if !defined _MSC_VER
	#error "Wrong Compiler. This library does only run with Visual C++ 7.1 and Visual C++ 6. To suppress this Error, uncomment this line."
#else
	#if _MSC_VER < 1200
		// older then VC6, too old to use library.
		#error "Wrong Compiler. This library does only run with Visual C++ 7.1 and Visual C++ 6. Older compiler versions are not supported."
	#elif _MSC_VER == 1200
		// VC6
	#elif _MSC_VER == 1300
		// VC70 not supported
		#error "Wrong Compiler. This library does only run with Visual C++ 7.1 and Visual C++ 6. VC7.0 is not supported."
	#elif _MSC_VER == 1310
		// VC71
	#elif _MSC_VER == 1400
		// VC80
	#elif _MSC_VER == 1500
		// VC90
	#else
		#error "Wrong Compiler. This library does only run with Visual C++ 7.1 and Visual C++ 6. Newer versions are currently not supported."
		// other maybe newer compiler ...
	#endif
#endif

そして、調べてみました_MSC_VERは、もともとコンパイラを定義するためのバージョンです.
MS VC++10.0 _MSC_VER=1600(VS2010)
MS VC++9.0 _MSC_VER=1500(VS2008)
MS VC++8.0 _MSC_VER=1400(VS2005)
MS VC++7.0 _MSC_VER=1300
MS VC++7.1 _MSC_VER=1310
MS VC++6.0 _MSC_VER=1200
プログラムに参加_MSC_VERマクロは、コンパイラバージョンに基づいてコンパイラに行を選択させるコンパイルプログラムを実行することができる.
たとえば、あるバージョンのコンパイラによって生成されたlibファイルが別のバージョンのコンパイラによって呼び出されない場合、アプリケーションを開発するときに、そのプログラムのlib呼び出しライブラリに複数のバージョンのコンパイラによって生成されたlibファイルが格納されます.[1]
この例は、ファイル内のコードです.
#if !defined UDSHL_LIB_NO_LINK
	#if (!defined _MSC_VER || _MSC_VER >= 1500)	// vc80 compiler, and other here
		#pragma warning( disable : 4996) // Disable deprecated warnings.

		#if defined _DEBUG
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc9d.lib" )
		#else
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc9.lib" )
		#endif
	#elif (!defined _MSC_VER || _MSC_VER >= 1400)	// vc80 compiler, and other here
		#pragma warning( disable : 4996) // Disable deprecated warnings.

		#if defined _DEBUG
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc8d.lib" )
		#else
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc8.lib" )
		#endif
	#elif (!defined _MSC_VER || _MSC_VER >= 1300)	// vc71 compiler, and other here
		#if defined _DEBUG
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc71d.lib" )
		#else
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc71.lib" )
		#endif
	#else
		#if defined _DEBUG
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc6d.lib" )
		#else
			#pragma comment ( lib, UDSHL_LIB_DIR "IAT_UDSHL07_vc6.lib" )
		#endif
	#endif

対応するライブラリ(IAT_UDSHL 07_vc**.lib)ファイルをバージョンによって選択します.debugとreleaseバージョンにも分けられます.
問題は、もし私がvs 2010だけをインストールしたらどうやって実行しますか?
プロジェクトのプロパティの変更->プラットフォームツールセット、v 90の選択後、ヒント
  	1	error MSB8010:         (v90)   Visual Studio 2008。           Visual Studio 2008。

[1]. _MSC_VER.http://baike.so.com/doc/515910.html