I am compiling a 3rd party library and don't care to fix the warnings present in the library, but I don't want them polluting the Issues pane in Qt Creator.
我正在编译一个第三方库,并且不关心如何修复库中的警告,但是我不希望它们污染Qt创建者的问题窗格。
I've tried following the advice here, but there is no compiler flag to disable -Wall
after it has been enabled, such as with -Wno-enum-compare
.
我试过遵循这里的建议,但是在启用后,没有一个编译器标志可以禁用-Wall,比如- wno - encompare。
After reading this, I tried removing the flag like so:
读完这篇文章后,我试着把旗子去掉:
CFLAGS -= -Wall
But that didn't work either. So I tried this advice:
但这也没有用。所以我尝试了这个建议:
QMAKE_CXXFLAGS_WARN_OFF -= -Wall
Still nothing.
还是什么都没有。
So I looked in the generated Makefile
and found this:
我在生成的Makefile中找到了这个:
CFLAGS = -pipe -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -g -fPIC -Wall -W -D_REENTRANT $(DEFINES)
So I tried removing the flag from those two variables:
所以我试着从这两个变量中移除标记:
CFLAGS -= -Wall
CXXFLAGS -= -Wall
Still nothing. How are you supposed to remove this compiler flag?!
还是什么都没有。你要如何移除这个编译器标志?!
2 个解决方案
#1
22
The simplest solution is:
最简单的解决方案是:
CONFIG += warn_off
Thanks to peppe in comments.
感谢peppe的评论。
Explanation
The -Wall
flag gets inserted into the Makefile
by these two variables:
这两个变量将-Wall标志插入Makefile中:
QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_ON
So to remove -Wall
, you need to remove it from both of those variables.
要移除-Wall,你需要从这两个变量中移除它。
QMAKE_CFLAGS_WARN_ON -= -Wall
QMAKE_CXXFLAGS_WARN_ON -= -Wall
warn_off
does just that.
warn_off就是干这个的。
#2
8
As "peppe" also noted in the comment, the Qt'ish way is this according to the documentation below: CONFIG += warn_off/on
正如在评论中提到的“peppe”,Qt'ish方法是根据下面的文档:CONFIG += warn_off/on。
warn_on
: The compiler should output as many warnings as possible. This is ignored if warn_off is specified.
warn_on:编译器应该输出尽可能多的警告。如果指定了warn_off,则忽略这个。
warn_off
: The compiler should output as few warnings as possible.
warn_off:编译器应该输出尽可能少的警告。
The CONFIG documentation can be found in here.
配置文档可以在这里找到。
The QMAKE_CXXFLAGS_WARN_OFF/ON
variables do not need to be set explicitly as they are handled by qmake.
在qmake处理的时候,不需要显式地设置QMAKE_CXXFLAGS_WARN_OFF/ON变量。
#1
22
The simplest solution is:
最简单的解决方案是:
CONFIG += warn_off
Thanks to peppe in comments.
感谢peppe的评论。
Explanation
The -Wall
flag gets inserted into the Makefile
by these two variables:
这两个变量将-Wall标志插入Makefile中:
QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS_WARN_ON
So to remove -Wall
, you need to remove it from both of those variables.
要移除-Wall,你需要从这两个变量中移除它。
QMAKE_CFLAGS_WARN_ON -= -Wall
QMAKE_CXXFLAGS_WARN_ON -= -Wall
warn_off
does just that.
warn_off就是干这个的。
#2
8
As "peppe" also noted in the comment, the Qt'ish way is this according to the documentation below: CONFIG += warn_off/on
正如在评论中提到的“peppe”,Qt'ish方法是根据下面的文档:CONFIG += warn_off/on。
warn_on
: The compiler should output as many warnings as possible. This is ignored if warn_off is specified.
warn_on:编译器应该输出尽可能多的警告。如果指定了warn_off,则忽略这个。
warn_off
: The compiler should output as few warnings as possible.
warn_off:编译器应该输出尽可能少的警告。
The CONFIG documentation can be found in here.
配置文档可以在这里找到。
The QMAKE_CXXFLAGS_WARN_OFF/ON
variables do not need to be set explicitly as they are handled by qmake.
在qmake处理的时候,不需要显式地设置QMAKE_CXXFLAGS_WARN_OFF/ON变量。