使用LLVM / Clang忽略特定文件中的所有警告 [英] Ignore all warnings in a specific file using LLVM/Clang

查看:555
本文介绍了使用LLVM / Clang忽略特定文件中的所有警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iOS项目中有一些文件有一些警告,我想忽略这些警告。我不想在整个项目中禁用警告(知道如何做),只是一些特定的文件。因此,有没有办法完全忽略来自特定文件的所有警告?

There are some files in my iOS project that have some warnings, and I want to ignore those warnings. I don't want to disable warnings in the entire project (know how to do that), just some specific files. So, is there a way to completely ignore all warnings from a specific file?

我在Xcode 4.2上使用LLVM 3.0和Clang。

I'm using LLVM 3.0 and Clang on Xcode 4.2.

推荐答案

如果你只是使用clang,那么你应该使用pragma语法为你维护的源(假设是不可能通过改变程序

if you're just using clang, then you should use the pragma syntax for sources you maintain (assuming it is impossible to remove the warning by altering the program appropriately).

这里是语法:

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmultichar"

char b = 'df'; // no warning.

#pragma clang diagnostic pop

如果这些程序不能更改,不要维护,您应该指定要禁用的文件的警告,而不是所有。要禁用所有,您可以添加每个文件参数 -w 。源更改,一些警告(或不)适用于不同的构建设置。

if these are programs you cannot change and don't maintain, you should specify the warning(s) to disable for the file, rather than all. to disable all, you can add the per file argument -w. sources change, and some warnings do (or do not) apply with different build settings. clang's messages can tell you what flag equates to the generated warning.

要使用Xcode更改文件的构建标志:

To use Xcode to alter a file's build flags:


  • 选择目标

  • 选择构建阶段

  • 找到文件以修改来源阶段

  • 双击其编译器标志单元格进行编辑

  • select the target
  • select the build phase
  • locate the file to modify the arguments in the "Compile Sources" phase
  • double click its "Compiler Flags" cell to edit

这篇关于使用LLVM / Clang忽略特定文件中的所有警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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