10

次の Boost Signals2 コードで Visual Studio 2012 Ultimate を使用しています: https://github.com/cfobel/boost_signals2/blob/master/hello_world_0.cpp で、次のエラーが生成されます。

c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory(348): error C4996: 'std::_Uninitialized_copy0': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>          c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory(333) : see declaration of 'std::_Uninitialized_copy0'
1>          c:\libraries\boost_1_52_0\boost\signals2\detail\auto_buffer.hpp(192) : see reference to function template instantiation '_FwdIt std::uninitialized_copy<I,boost::variant<T0_,T1>*>(_InIt,_InIt,_FwdIt)' being compiled

このコードは Visual Studio 2012 C++ と互換性がありませんか? まだ安全に使用できますか?最後に、提案どおりに変更するにはどうすればよいですか? ありがとう

4

1 に答える 1

11

C4996は、非推奨とマークされた関数の使用に関する警告です。エラーとして表示されているので、Treat Warning as Error (/WX)オプションが有効になっている可能性がありますか?

これを無効にする方法は、エラー メッセージ自体に記載されています。_SCL_SECURE_NO_WARNINGSプロジェクトのプリプロセッサ定義にシンボルを追加します。

于 2013-01-14T21:57:35.827 に答える