Visual Studio 2012 C ++使用Boost Signal2编译错误

时间:2013-01-14 21:51:13

标签: c++ visual-studio boost boost-signals2

我正在使用带有以下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 ++不兼容吗?它还可以安全使用吗?最后,如何按照建议进行更改? 感谢

1 个答案:

答案 0 :(得分:11)

C4996是关于使用已标记为已弃用的函数的警告。既然您将其视为错误,那么您可能启用了Treat Warning as Error (/WX)选项吗?

错误消息本身描述了禁用此方法的方法。将_SCL_SECURE_NO_WARNINGS符号添加到项目的预处理器定义中。