I had issues a while back getting std::variant to work in a QtCreator project, facing similar complaints here:
Can't use c++17 features using g++ 7.2 in QtCreator
I resolved this issue, and have been happily working on this project for some time with no further issues. This was running on ubuntu 14.04, built with GCC 7.2.0, and built under clang 5.0 aswell.
Two days ago I backed everything up, installed the latest QtCreator, installed all my tools again (gcc 7.2.0 and clang 5.0) retrieved my project and tried to build. The build fails, stating:
/usr/include/c++/7.2.0/bits/c++17_warning.h:32: 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.
In my project file, I already have this:
QMAKE_CXXFLAGS += -std=c++17
And I can see in the phrase "-std=c++17" in the compiler output. Here is the complete compiler output up until the first error:
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 \
^
So, as you can see, the -std=c++17 flag is set. Is there an issue with flag order here?
The next curious thing is that whether I use my gcc kit or clang kit in QtCreator, it always seems to call clang in the compiler output, shown in this line:
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
and it mentions clang again near the end of that line with this include flag:
-I../../../../Programming/Qt/5.10.0/gcc_64/mkspecs/linux-clang
I have quadruple checked up kits, and the GCC one definitely calls GCC and GCC++, and the Clang one definitely calls Clang and Clang++. I have checked the executable links and followed their link paths step by step, /usr/bin/gcc definitely links to /usr/bin/x86_64-linux-gnu-gcc-7 and /usr/bin/g++ definitely links to /usr/bin/x86_64-linux-gnu-g++-7. So I am baffled as to why it insists on calling Clang instead of GCC when I have the GCC kit selected! Regardless, my versions of both GCC and Clang support c++17, so this should not be the cause of my issues anyway should it?