簡體   English   中英

當-std = c ++ 17在編譯器輸出中時,使用-std ++ 17標志請求為std :: variant啟用c ++ 17支持的編譯器

[英]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 :: variant在QtCreator項目中工作,這里面臨着類似的抱怨:

不能在QtCreator中使用g ++ 7.2使用c ++ 17功能

我解決了這個問題,並且很樂意在這個項目上工作一段時間而沒有其他問題。 這是在ubuntu 14.04上運行的,使用GCC 7.2.0構建,並在clang 5.0下構建。

兩天前我支持所有內容,安裝了最新的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和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一起構建:

Clang Release,Clang Debug,GCC Debug。

但不是在使用此套件時:

GCC發布。

我已經徹底檢查了選項和工具包設置,我看不出任何錯誤,所以我會針對這些問題打開一個新的更合適的問題,我會在回答原始問題時發布鏈接以防其他人閱讀我的問題問題也有這些問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM