c++ - 使用 C++11 时列表中的编译错误
问题描述
使用 std=c++11 选项编译 C++ 代码时出现以下错误。
In file included from /usr/include/c++/7/list:63:0,
from /usr/include/qt4/QtCore/qlist.h:51,
from /usr/include/qt4/QtCore/QList:1,
/usr/include/c++/7/bits/stl_list.h:591:68: error: ‘std::is_nothrow_default_constructible<typename std::__cxx11::_List_base<_Tp, _Alloc>::_Node_alloc_type>::value’ is not a type
noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value)
代码编译,如果我使用 std=c++98 选项!但我需要使用 C++11 编译它。
解决方案
正如 ZanLynx 正确怀疑的那样,错误是从代码的其他部分引发的。我使用的是旧版本“0.9.9”SQLiteCpp (github.com/SRombauts/SQLiteCpp)。为了检测他们使用的 C++11 编译器#if (defined(GNUC) && (GNUC >= 4 && GNUC_MINOR >= 7 ) && defined(GXX_EXPERIMENTAL_CXX0X))
,它没有按预期工作。我将其更改为#if (__cplusplus >= 201103L)
删除了错误。谢谢赞林克斯!
推荐阅读
- c - 不包括两次相同数字的数字总和
- javascript - 向分页 url.action 添加属性?
- python - 如何使用条件合并数据框?
- matlab - MATLAB 绘制图像,8 种颜色的索引图像,第一个图上的 8 个颜色框和索引,第二个图绘制图像的 0-7 个索引作为图像
- three.js - 如何仅使用脚本更改three.js / editor中的相机?
- java - 将字节流解析成大对象
- android - 检测设备是用针锁或面部锁的指纹锁保护的吗?
- php - PHP分组多维数组独立处理每组数组
- c++ - 我可以在普通构造函数之前使用全局对象吗?
- javascript - 为什么 node.js 承诺即使放在 then() 块中也不会解决?