指定した区間のワーニングを抑制します。 ワーニングを抑制するには、 #pragma warning(diable:ワーニングの番号) を記載する事で、以降の行からそのワーニングは出なくなります。 特定の行だけワーニングを出ないようにするには、 #pragma warning(push)と #pragma warning(pop)の間で、 #pragma warning(disable:ワーニング番号) を宣言します。
#include <stdio.h>
#include <tchar.h>
#include <locale.h>
#include <iostream>
#include <windows.h>
int _tmain
(
int argc
, _TCHAR* argv[]
)
{
// 標準出力にユニコードを表示する
setlocale( LC_ALL, "Japanese" );
// pushとpopで囲んだ部分だけワーニングが出なくなります。
#pragma warning(push)
#pragma warning(disable:4996)
// この間はワーニング番号4996は出ません
if ( 0 == ::wcsicmp( L"aaa", L"bbb" ) ) {
std::wcout << L"一致しました。" << std::endl;
}
#pragma warning(pop)
// こからはワーニング番号4996は出ます
if ( 0 == ::wcsicmp( L"aaa", L"bbb" ) ) {
std::wcout << L"一致しました。" << std::endl;
}
// 正常終了
return( 0 );
}
1>g:\pragma_warning_push_pop.cpp(27) : warning C4996: 'wcsicmp': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _wcsicmp. See online help for details. 1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\wchar.h(1107) : 'wcsicmp' の宣言を確認してください。