首页 > 解决方案 > 升压信号2没有被编译

问题描述

#include <boost/signals2.hpp>当我在 VS 中添加标题时

即使它能够找到标题,我也会收到以下错误。

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库头文件工作正常并且代码是可编译的。所以我认为boost安装没有问题。

Edit1:我从boost网站下载了 windows prebuild 二进制文件并安装了。我正在使用VS 2017。我添加了库的路径,属性中的标题如下。

配置属性->链接->常规->附加库目录为 C:\boost_1_69_0\lib64-msvc-14.1;

配置属性->包含目录添加了附加文件夹 C:\boost_1_69_0;

Edit2:通过添加 -D_SCL_SECURE_NO_WARNINGS 解决了问题

配置属性->C/C++->命令行。

标签: c++boostcompiler-errors

解决方案


我假设您正在使用 VS 2017 在 Windows 上进行编译。

C4996 实际上是一个警告(编译器警告 C4996),而不是错误,因此您可能已经激活了将所有警告视为错误的选项。要检查,请右键单击目标属性,然后展开“C/C++”,然后转到常规属性,如以下快照所示:

在此处输入图像描述

在此处输入图像描述

如果我的假设是错误的,请添加必要的信息(编译器/操作系统/您是如何获得 boost,是否正确编译,....),以便我们找到更好的答案。

编辑:由于您声明您没有更改编译选项,因此您应该在源代码中的某处搜索源代码以查找#pragma warninng(error:....)


推荐阅读