使用 C++11 时列表中出现编译错误

Compilation error in list while using C++11

本文关键字:编译 错误 C++11 列表 使用      更新时间:2023-10-16

在使用 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正确怀疑的那样,错误是从代码的其他部分抛出的。 我使用的是SQLiteCpp(github.com/SRombauts/SQLiteCpp(,一个旧版本"0.9.9"。为了检测C++11编译器,他们使用了#if (defined(GNUC) && (GNUC >= 4 && GNUC_MINOR >= 7 ) && defined(GXX_EXPERIMENTAL_CXX0X)),它没有按预期工作。我将其更改为#if (__cplusplus >= 201103L),从而消除了错误。 谢谢赞山猫!