Visual Studio 2012 c++编译Boost Signal2错误

Visual Studio 2012 C++ compile error with Boost Signal2

本文关键字:Boost Signal2 错误 编译 c++ Studio 2012 Visual      更新时间:2023-10-16

我使用Visual Studio 2012 Ultimate与以下Boost Signals2代码:在https://github.com/cfobel/boostrongignals2/blob/master/hello_world_0.cpp它会生成以下错误:

c:program files (x86)microsoft visual studio 11.0vcincludexmemory(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.0vcincludexmemory(333) : see declaration of 'std::_Uninitialized_copy0'
1>          c:librariesboost_1_52_0boostsignals2detailauto_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++吗?它仍然可以安全使用吗?最后,我如何按照建议进行更改?由于

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

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