Is there a way to suppress warnings in Xcode?

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"

Where warning name is some gcc warning flag.

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.

Leave a Comment