当我在VS中添加标题#include <boost/signals2.hpp>
时
即使能够找到 header ,我也收到以下错误。
1>signals.cpp
1>c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\memory(53): error C4996: 'std::uninitialized_copy::_Unchecked_iterators::_Deprecate': Call to 'std::uninitialized_copy' 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:\apps\mvs15\vc\tools\msvc\14.10.25017\include\memory(53): note: see declaration of 'std::uninitialized_copy::_Unchecked_iterators::_Deprecate'
1>c:\boost_1_69_0\boost\signals2\detail\auto_buffer.hpp(191): note: see reference to function template instantiation '_FwdIt *std::uninitialized_copy<I,boost::shared_ptr<void>*>(_InIt,_InIt,_FwdIt)' being compiled
我无法解决此问题。但是我的
Boost.Asio
库 header 可以正常工作,并且代码可以编译。因此,我认为Boost安装没有问题。Edit1:我从boost网站下载并安装了Windows prebuild二进制文件。我正在使用VS2017。已将库路径添加到属性中的 header ,如下所示。
Configuration Properties->Linked->General->Additional Library Directories as C:\boost_1_69_0\lib64-msvc-14.1;
Configuration Properties->Include Directories added additional folder C:\boost_1_69_0;
Edit2:通过在-D_SCL_SECURE_NO_WARNINGS中添加解决了问题
Configuration Properties->C/C++->Command Line.
最佳答案
我假设您正在使用VS 2017在Windows上进行编译。
C4996实际上是警告(compiler warning C4996),不是错误,因此您可能已激活将所有警告视为错误的选项。要进行检查,请右键单击目标属性,然后展开“C/C++”,然后转到“常规”属性,如以下快照所示:
如果我的假设是错误的,请添加必要的信息(compiler/os/,您是如何获得boost的,如何正确编译的……),以便我们找到更好的答案。
编辑:
由于您已声明未更改编译选项,因此应在源代码中的某处在源代码中搜索#pragma warninng(error:....)。
关于c++ - Boost信号2未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53881649/