如何添加“警告作为错误”规则到Qt .pro文件? [英] how-to add "warnings as error" rule to Qt .pro file?
问题描述
当我通常在一个 C ++
项目工作时,我做的第一件事之一就是在我的编译器上设置警告作为错误。
使用 Qt
时, qmake
生成 Makefile
,并且不在编译命令中包括此选项。我确定有一种方法来添加这样的选项(和其他人)到生成的 Makefile
,但我不能弄清楚。
我该如何做?
我使用的开源版本 Qt
您可以使用 QMAKE_CXXFLAGS
在pro文件中指定编译器标志:
QMAKE_CXXFLAGS + = -Werror
When I usually work on a C++
project, one of the first things I do is setting up the "treat warning as errors" on my compiler.
When using Qt
, qmake
generates the Makefile
for you and doesn't include this option on the compilation commands. I'm pretty sure there is a way to add such an option (and others) into the generated Makefile
but I couldn't figure it out.
How would I do that ?
I'm using the open-source version of Qt
with g++
as the compiler.
You can use QMAKE_CXXFLAGS
in pro file to specify compiler flags:
QMAKE_CXXFLAGS += -Werror
这篇关于如何添加“警告作为错误”规则到Qt .pro文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!