如何在Qt Creator中抑制警告 [英] How to suppress warnings in Qt Creator

查看:2359
本文介绍了如何在Qt Creator中抑制警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的g ++ - 4.5打印:


我想知道是否可以在Qt-Creator中禁止编译器特定的警告。


警告:条件表达式中的枚举类型和非枚举类型

因为它非常烦人。




  • Ubuntu 11.04 x64

  • g ++ - 4.5

  • QtCreator 2.01

  • Qt 4.7


谢谢!

解决方案

您需要使用这个:


QMAKE_CXXFLAGS + = -Wno-enum-compare


如果您收到以结尾的警告 - 例如:Wenum-compare

另外,请注意,根据GCC文档
看看这个你无法压制的东西,t帽子的方式你没有给你
的错误想法,你的标志是不正确的。



知道标志是否传递给编译器显然是查看编译器输出,并确保你的标志在那里,你应该在命令行中看到 -Wno-enum-compare ,例如,即使标志没有压制一切。您会惊讶地发现这样的信息有多困难,需要进行一些挖掘,并且我最终从编译.pro文件时使用的自动完成功能中找到了它,如果您在编辑.pro文件时遇到问题,点击 Ctrl +空格(或开始键入单词并按 Home 键),以获取可在.pro文件中使用的有效内容列表其他常见的源文件。它帮助我找到了正确的东西( QMAKE_CXXFLAGS ,事实证明,出于某种原因通常不是人们的建议)......噢,这是关于Qt 4.8版本,创建者2.4的,所以它可能已经改变了,因为这篇文章(他们似乎很喜欢这么做,我看到新版本已经发生了巨大变化)。


I'm wondering if it is possible to suppress compiler specific warnings in Qt-Creator.

My g++-4.5 prints:

warning: enumeral and non-enumeral type in conditional expression

I would like to get rid of it, because it's very annoying.

  • Ubuntu 11.04 x64
  • g++-4.5
  • QtCreator 2.01
  • Qt 4.7

Thank you!

解决方案

You need to use this:

QMAKE_CXXFLAGS += -Wno-enum-compare

if you get a warning that ends in -Wenum-compare, for example.

Also, note that some warnings cannot be suppressed as per the GCC documentation take a look at this for ones that you can't suppress, that way you are not given the false idea that your flags aren't working right.

The best way to know if the flags are being passed to the compiler, obviously, is to look at the compiler output, and make sure your flags are there, you should see -Wno-enum-compare in the command line, for example, even if the flag does not suppress anything. You'd be surprised how hard it can be to find information about stuff like this, it took some digging and I ended up finding it from the auto-complete that works when editing .pro files, if you have problems editing your .pro files, hit Ctrl+Space (or start typing a word and hit Shift+Home), to get a list of valid things you can use in your .pro file just like any other usual source file. It helped me find the right thing (QMAKE_CXXFLAGS, as it turns out, is usually not what people suggest, for some reason)... Oh yeah and this is about Qt version 4.8, creator 2.4, so it may have changed, since this post (they seem to like to do that a lot, i saw the newer versions already have changed drastically).

这篇关于如何在Qt Creator中抑制警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆