c++ - Boost信号2未编译

标签 c++ boost compiler-errors

当我在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++”,然后转到“常规”属性,如以下快照所示:

enter image description here

enter image description here

如果我的假设是错误的,请添加必要的信息(compiler/os/,您是如何获得boost的,如何正确编译的……),以便我们找到更好的答案。

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

关于c++ - Boost信号2未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53881649/

相关文章:

c# - C# 中的 ref 和 out 是否与 C++ 中的指针相同?

c++ - cpp/opengl 中的事件

c++ - boost::shared_ptr 和动态转换

javascript - 如何在JavaScript中使用$ {var}变量?

c++ - 无法在赋值中将 'int*' 转换为 'ABC*'

javascript - React Native Undefined 不是一个对象(评估'userData.id)

c++ - 为什么有必要在函数定义中包含返回类型,即使它已在声明中指定?

c++ - 基类变量为 `not declared in its scope`

c++ - unordered_multimap 元素插入

c++ - scoped_lock 如何避免发出 "unused variable"警告?