【发布时间】:2020-04-20 19:47:09
【问题描述】:
使用 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 编译它。
【问题讨论】:
-
奇怪。这是第一个错误和整个错误消息吗?
-
你做了一些奇怪的事情。无论放入列表中的类都无法创建
is_nothrow_default_constructible模板。由于它唯一能做的事情是真或假,这意味着很可能根本无法构造该类。我们肯定需要查看更多代码。并且一定要尝试制作一个只包含一个类而不是所有 Qt 垃圾的小型测试程序,看看它是否可以编译。 -
我的超能力表明,在 2005 年至 2011 年间开发的 Qt 4 不符合 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++ qt c++11 compiler-errors noexcept