Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

xcode - Ignore all warnings in a specific file using LLVM/Clang

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?

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I inherited a project that contained a lot of 320 code, and that code base threw several warnings and static analyzer errors at me that I had no interest in fixing since I will be removing that code from the project in the near future.

You can disable static analyzer warnings for a specific file by including the following compiler flag:

-Xanalyzer -analyzer-disable-all-checks

You can combine this with -w to disable warnings for that file as well. That has allowed me to push forward with new development while not having to be pestered with the 30 or so warnings generated by that code base.

Using the instructions from above: To use Xcode to alter a file's build flags:

  1. select the target
  2. select the build phase
  3. locate the file to modify the arguments in the "Compile Sources" phase
  4. double click its "Compiler Flags" cell to edit
  5. add "-w -Xanalyzer -analyzer-disable-all-checks" to suppress warnings and clang warnings

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...