有没有办法抑制 Xcode 中的警告? [英] Is there a way to suppress warnings in Xcode?

查看:40
本文介绍了有没有办法抑制 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.

这会覆盖命令行上的任何警告标志.但是,它不适用于所有警告.将 -fdiagnostics-show-option 添加到您的 CFLAGS,您可以查看可以使用哪个标志来禁用该警告.

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屋!

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