[英]Suppressing “use of the 'X' attribute is a C++17 extension” warnings
I'm using Qt Creator and I have CONFIG += c++17
in my .pro file, and I'm using the nodiscard
attribute where appropriate. 我正在使用Qt Creator,并且我的.pro文件中有
CONFIG += c++17
,并且在适当的地方使用了nodiscard
属性。 However, the compiler still needlessly warns that use of the '[[nodiscard]]' attribute is a C++17 extension
. 但是,编译器仍会不必要地警告
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"?
甚至所有类型为“ X是C ++ XX扩展名”的警告? I've looked everywhere for a flag to include in
CXXFLAGS
without success. 我到处都在寻找将标志包含在
CXXFLAGS
而没有成功的标志。
I'm using Qt Creator version 4.9.2 and g++ version 8.3.0 我正在使用Qt Creator版本4.9.2和g ++版本8.3.0
Since Qt 5.12 you can use config flag CONFIG += c++17
从Qt 5.12开始,您可以使用配置标志
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. 在Qt 5.12之前,您需要通过qmake标志添加编译器标志:GCC和MinGW的
QMAKE_CXXFLAGS += -std=c++17
和QMAKE_CXXFLAGS += /std:c++latest
或QMAKE_CXXFLAGS += /std:c++17
< -取决于您使用的MSVC编译器。
Here is Qt qmake manual variable reference for more info 这是Qt qmake手动变量参考,以获取更多信息
And Gerrit code review of task QTBUG-67527 for even more info 有关任务QTBUG-67527的 Gerrit代码审查,甚至更多信息
After you have added this flags: 添加此标志后:
run qmake on the project again 再次在项目上运行qmake
clean your project. 清理您的项目。 (delete shadow build folder if necessary)
(如有必要,请删除阴影构建文件夹)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.