Visual
Studioの変更履歴
はじめに
CmtoyのプロジェクトをVisualStudioの各バージョンで再ビルドした結果をまとめました。
Cmtoyの構成はMFCを使用したマルチバイト文字セットの32bitダイアログアプリケーションとWindows 拡張DLLです。現在Windows10にVisual
Studio6.0をインストールしてCmtoyの開発をしています。Visual Studio6.0からアップグレードすることを想定して、Visual
Studio6.0のCmtoyプロジェクトを変換して再コンパイルした結果を調べてみました。
Visual Studio2017まではVisual Studio6.0のプロジェクトワークスペースファイル(*.dsw)を直接開き、変換できます。VisualStudio2019ではVisualStudio2017のソリューションファイル(*.sln)を開くことで変換しました。
各バージョンで変更となったコンパイラの機能を報告します。(Cmtoyの使っている機能に関係するものだけですが整理しました)
調査結果
|
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
|
C/C++ コンパイラ バージョン _MSC_VER |
VS6のプロジェクトの変換 |
Windows バージョン WINVER |
エディットコンティニュー |
Windows Sockets関数 gethostbyname |
マルチバイト文字セット _MBCS |
アンセーフ CRT ライブラリ関数
|
POSIX 関数名
|
MFC関数 CWinApp::Enable3dControls |
MFC列挙子 CFileException::generic |
std::sort()のpred() |
VS6 |
1200 |
可 |
0x0500 |
可 |
|
|
|
|
|
generic |
なし |
VS2003 |
1310 |
可 |
0x0500 |
可 |
|
|
|
|
warning C4996 |
generic |
なし |
VS2008 |
1500 |
可 |
0x0500 |
可 |
|
|
|
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
VS2010 |
1600 |
可 |
0x0500 |
可 |
|
|
警告C4996 |
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
VS2013 |
1800 |
可 |
0x0501 |
可 |
警告C4996 |
警告C4996 |
警告C4996 |
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
VS2015 |
1900 |
可 |
0x0501 |
不可 |
警告C4996 |
警告C4996 |
警告C4996 |
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
VS2017 |
1916 |
可 |
0x0501 |
不可 |
警告C4996 |
警告C4996 |
警告C4996 |
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
VS2019 |
1929 |
不可 |
0x0501 |
不可 |
警告C4996 |
警告C4996 |
警告C4996 |
警告C4996 |
warning C4996 |
genericExceptionを推奨 |
採用 |
1. C/C++コンパイラバージョン
マイクロソフト社が定義しているプリプロセッサマクロ_MSC_VERの値。
調査したときに使ったコンパイラの定義している値を載せました。
2. VisualStudio6.0のプロジェクトワークスペースファイル(*.dsw)を直接開くことができるかどうか。開ける場合は「可」。
3. コードがサポートするWindowsオペレーティングシステムの最小バージョンを指定するプリプロセッサマクロWINVERの値。
4.コンパイラのスイッチ
「error D8016: コマンド
ライン オプション '/ZI' と '/Gy-' は同時に指定できません。」が発生する。
デバッグ情報の形式を「プログラムデータベース(/Zi)」に変更してコンパイル可能となる。
5.Platform SDK: Windows Socketsに含まれる関数gethostbynameとinet_ntoa
「warning C4996:
'gethostbyname': Use getaddrinfo()
or GetAddrInfoW() instead or define
_WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings」が発生する。
「warning C4996:
'inet_ntoa': Use inet_ntop()
or InetNtop() instead or define
_WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings」が発生する。
6.マルチバイト文字セットのアプリケーション
「warning C4996:
'MBCS_Support_Deprecated_In_MFC': MBCS support in MFC
is deprecated and may be removed in a future version of MFC」が発生する。
マイクロソフト社のドキュメントには以下の説明がある。
「マルチバイト文字セット
(MBCS: Multibyte Character Set) は、日本語や中国語など、1 バイト文字では表現できない文字セットをサポートするニーズに対する古いアプローチです。
新規開発を行う場合は、エンド ユーザーに対して表示されることのないシステム文字列を除き、すべてのテキスト文字列で
Unicode 文字列を使用する必要があります。」
7.安全でないCランタイムライブラリ関数
「warning C4996:
'sprintf': This function or variable may be unsafe.
Consider using sprintf_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS.」が発生する。
ライブラリ関数'sprintf','strcpy','strncpy', '_splitpath','sscanf','strtok','fopen','getenv','vsprintf','_vsnprintf','strncat','strcat'などで発生。
Stdafx.hでプリプロセッサマクロ_CRT_SECURE_NO_WARNINGSを定義して警告を抑制できる。
8.POSIX関数名
「warning C4996:
'stricmp': The POSIX name for this item is
deprecated. Instead, use the ISO C++ conformant name: _stricmp.
See online help for details.」が発生する。
Stdafx.hでプリプロセッサマクロ_CRT_NONSTDC_NO_WARNINGSを定義して警告を抑制できる。
9.MFC関数'CWinApp::Enable3dControls'
「warning C4996:
'CWinApp::Enable3dControls' が古い形式として宣言されました。」が発生する。
10.MFCのクラスCFileExceptionないで定義しているenum
「warning C4996:
'CFileException::generic': CFileException::generic
clashes with future language keyword generic and should not be used. Use CFileException::genericException
instead.」が発生する。
11.標準ライブラリ関数std::sort()
template<class
_RanIt, class _Pr>
inline
void sort(_RanIt _First, _RanIt _Last, _Pr _Pred);
sort関数に渡す比較関数_Predが厳密弱順序(a strict weak ordering)となったため、比較結果が一致した場合にtrueを返すとプログラムがハングする。厳密弱順序の説明がどうもわかりにくかったのだが、比較結果が一致した場合はfalseを返してリストの入れ替えをしないようにするということのようだ。
その他気がついた項目を挙げておく。
C++ランタイムライブラリ関数のプロトタイプがVS2017で変更になったようだ。
|
VS6.0 |
VS2017 |
strstr |
char *strstr( const char *string1, const char *string2 ); |
char *strstr( char *str, const char *strSearch ); // C++
only |
const char *strstr( const char *str, const char *strSearch ); // C++
only |
||
strchr |
char *strchr( const char *string, int c ); |
char *strchr( char * str, int c ); // C++ only |
const char *strchr( const char * str, int c ); // C++ only |
考察
以上の警告項目はそのままで出力を抑制、11は修正して動作するようになった。
すべて64ビット版Windows10上で確認した。
VisualStudio6.0はCodeProjectの以下の記事を参考にWindows10にインストールした。
Install
Visual Studio 6.0 on Windows 10