本文介绍了Qt编译器标志顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是摆脱一些类型的编译器警告。我发现我可以这样做,通过在我的.pro文件中添加编译器标志:

My goal is to get rid of some types of compiler warnings. I found out that I can do that by adding compiler flags in my .pro file:

QMAKE_CXXFLAGS += -Wno-unused-variable -Wno-reorder

问题是,它们是在Qt构建系统生成的标志之前添加的。我检查了我的编译器输出:

The problem is that they are added before flags that are generated by Qt build system. I've examined my compiler output:

所以,你可以看到 - 墙在我的标志后,丢弃它们。

So as you can see -Wall goes after my flags and discards them. What should I do to add those flags after ?

推荐答案

不要使用 QMAKE_CXXFLAGS ,而是重写 QMAKE_CXXFLAGS_WARN_ON 并附上您自己的警告:

Don't use QMAKE_CXXFLAGS but rather override QMAKE_CXXFLAGS_WARN_ON with your own warnings:

QMAKE_CXXFLAGS_WARN_ON = -Wno-unused-variable -Wno-reorder

这篇关于Qt编译器标志顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:18