有没有办法抑制Xcode中的警告? [英] Is there a way to suppress warnings in Xcode?
问题描述
有没有办法抑制Xcode中的警告?
Is there a way to suppress warnings in Xcode?
例如,我调用一个未记录的方法,由于该方法不在标题中,我得到一个警告编译。我知道我可以添加到我的标题停止警告,但我想知道是否有一种方式,而不是添加到标题(所以我可以保持标题干净和标准),以抑制警告? pragma或某事?
For example I am calling an undocumented method and since the method is not in the header I get a warning on compile. I know I can add it to my header to stop the warning, but I am wondering if there is a way other than adding it to the header (so I can keep the headers clean and standard) to suppress the warning? A pragma or something?
推荐答案
要禁用基于每个文件的警告,使用Xcode 3和llvm-gcc-4.2可以使用:
To disable warnings on a per-file basis, using Xcode 3 and llvm-gcc-4.2 you can use:
#pragma GCC diagnostic ignored "-Wwarning-flag"
其中警告名称是一些gcc警告标志。
Where warning name is some gcc warning flag.
这将覆盖命令行上的任何警告标志。它不工作与所有警告,虽然。向您的CFLAGS添加-fdiagnostics-show选项,您可以查看可用于停用该警告的标志。
This overrides any warning flags on the command line. It doesn't work with all warnings though. Add -fdiagnostics-show-option to your CFLAGS and you can see which flag you can use to disable that warning.
这篇关于有没有办法抑制Xcode中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!