请求C 17的编译器通过使用-STD 17标志在-STD = C 17时,将启用STD ::变体的支持
Compiler requesting c++17 support to be enabled for std::variant by using the -std++17 flag when -std=c++17 is in compiler output
我有一段时间的问题遇到了std ::变体以在qtcreator项目中工作,在这里面对类似的投诉:
无法使用QTCreator中的G 7.2使用C 17功能
我解决了这个问题,并且在没有进一步的问题的情况下一直很乐意从事这个项目。这是在Ubuntu 14.04上运行的,该4.04使用GCC 7.2.0构建,并在Clang 5.0 Aswell下建造。
。两天前,我备份了所有内容,安装了最新的QTCreator,再次安装了所有工具(GCC 7.2.0和Clang 5.0),然后检索了我的项目并尝试构建。构建失败,说明:
/usr/include/c /7.2.0/bits/c 17_warning.h:32:错误:此文件 需要编译器和库支持ISO C 2017标准。 必须使用-STD = C 17或-std = GNU 17启用此支持 编译器选项。
在我的项目文件中,我已经有一个:
QMAKE_CXXFLAGS += -std=c++17
我可以在编译器输出中的" -std = C 17"短语中看到。这是完整的编译器输出,直到第一个错误:
15:08:37: Running steps for project AIRadioQt...
15:08:37: Skipping disabled step qmake.
15:08:37: Starting: "/usr/bin/make"
/home/pete/Programming/Qt/5.10.0/gcc_64/bin/qmake -o Makefile ../AIRadioQt/AIRadioQt.pro -spec linux-clang CONFIG+=debug CONFIG+=qml_debug
clang++ -c -pipe -std=c++17 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_DATAVISUALIZATION_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AIRadioQt -I. -I../src -I../src/AIBase -I../src/Maths -I../src/Random -isystem /usr/local/include/csound -I../../../../Programming/Qt/5.10.0/gcc_64/include -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtDataVisualization -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtWidgets -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtGui -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I../../../../Programming/Qt/5.10.0/gcc_64/mkspecs/linux-clang -o main.o ../AIRadioQt/main.cpp
In file included from ../AIRadioQt/main.cpp:1:
In file included from ../AIRadioQt/stdafx.h:9:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/variant:35:
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/c++17_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2017 standard. This support must be enabled with the -std=c++17 or -std=gnu++17 compiler options.
#error This file requires compiler and library support
^
因此,如您所见,设置了-std = C 17标志。这里有标志订单的问题吗?
下一个奇怪的事情是,无论我是在qtcreator中使用我的GCC套件还是Clang套件,它似乎总是在编译器输出中调用Clang,在此行中显示:
clang++ -c -pipe -std=c++17 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_DATAVISUALIZATION_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../AIRadioQt -I. -I../src -I../src/AIBase -I../src/Maths -I../src/Random -isystem /usr/local/include/csound -I../../../../Programming/Qt/5.10.0/gcc_64/include -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtDataVisualization -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtWidgets -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtGui -I../../../../Programming/Qt/5.10.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I. -I../../../../Programming/Qt/5.10.0/gcc_64/mkspecs/linux-clang -o main.o ../AIRadioQt/main.cpp
,它在该行的尽头附近再次提到clang,其中包括标志:
-I../../../../Programming/Qt/5.10.0/gcc_64/mkspecs/linux-clang
我已经检查了四倍的套件,而GCC肯定会称呼GCC和GCC ,而Clang肯定称为Clang and Clang 。我已经检查了可执行的链接,并遵循他们的链接路径逐步,/usr/bin/gcc绝对链接到/usr/bin/x86_64-linux-gnu-gcc-7和/usr/bin/g 绝对链接到/usr/bin/x86_64-linux-gnu-g -7。因此,当我选择GCC套件时,我坚持要打电话给Clang而不是GCC感到困惑!无论如何,我的GCC和Clang的版本都支持C 17,所以这不应该是我问题的原因?
正如Galik上面指出的那样,编译器标志" -std = gnu 11"出现在标志" -std = c 17"之后,因此将其覆盖,这是此错误的原因。
我的编译器输出中此额外标志的这种外观目前是一个谜。它仅在使用Clang而不是使用GCC构建时才会出现,并且出于某种原因选择以下任何一个套件时,QtCreator正在用Clang构建:
叮当声释放,叮当调试,GCC调试。
,但使用此套件时不会:
GCC版本。
我已经彻底检查了选项和工具包设置,我看不到任何错误,因此我将为这些问题打开一个更合适的问题,如果有人回答,我将在我的原始问题中发布链接否则阅读我的问题也有这些问题。
- 使用std::multimap迭代器创建std::list
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 在 Eclipse 上启用 C++17 以使用 'std::byte'
- 视觉 std::矢量无异常:警告 C4530:使用了C++异常处理程序,但未启用展开语义.指定 /EHsc
- 如何使用 CMake 在 VS2017 中启用 /std:c++17
- 请求C 17的编译器通过使用-STD 17标志在-STD = C 17时,将启用STD ::变体的支持
- 为什么 MSVC++ 需要 std::setprecision 才能使用 std::hexfloat 启用全精度输出
- 如何在Android上启用STD ::实验::可选
- 如果向量是特定的长度,则使用C++11 std::enable_if来启用成员函数
- std::启用 C++11 时的矢量性能回归
- "using std::swap"如何启用 ADL?
- 启用-std=c++0x或-std=gnu++0x编译器选项
- clang中是否有一组已知的' c++11 '特性默认启用而不需要' -std=c++11 ' ?
- 警告:非静态数据成员初始化器只能使用-std=c++11或-std=gnu++11[默认启用]
- 在类上启用std::get支持
- 启用-std=c++0x时,自定义分配器的编译问题
- Std::istream不会抛出eof异常(已启用)
- 为什么在GCC 5.1中仍然启用COW std::字符串优化
- 启用多线程来使用std::thread:不允许操作
- 'for each'不是 std 的成员。 已启用 C++11 支持