Reputation: 521
I'm using Qt Creator and I have CONFIG += c++17
in my .pro file, and I'm using the nodiscard
attribute where appropriate. However, the compiler still needlessly warns that use of the '[[nodiscard]]' attribute is a C++17 extension
.
Is there a way to suppress that particular warning? Or even all warnings of the type "X is a C++XX extension"? I've looked everywhere for a flag to include in CXXFLAGS
without success.
I'm using Qt Creator version 4.9.2 and g++ version 8.3.0
Upvotes: 1
Views: 560
Reputation: 2232
Since Qt 5.12 you can use config flag CONFIG += c++17
Before Qt 5.12 you need to add compiler flags through qmake flags: QMAKE_CXXFLAGS += -std=c++17
for GCC & MinGW and QMAKE_CXXFLAGS += /std:c++latest
or QMAKE_CXXFLAGS += /std:c++17
<- depends on MSVC compiler you are using.
Here is Qt qmake manual variable reference for more info
And Gerrit code review of task QTBUG-67527 for even more info
After you have added this flags:
run qmake on the project again
clean your project. (delete shadow build folder if necessary)
Upvotes: 1