views:

864

answers:

1

Is there a #pragma to have gcc/Xcode suppress specific warnings, similar to Java's @SuppressWarning annotation?

I compile with -Wall as a rule, but there are some situations where I'd like to just ignore a specific warning (e.g. while writing some quick/dirty code just to help debug something).

I'm not looking for "fix the code" answers.

+1  A: 

Here's a viable solution. Use #pragma GCC system_header to let GCC handle your code in a very special way, thus suppressing any non fatal #warning.

Remeber you're just fooling your preprocessor, not the real compiler. Suppressing warnings could be harmful most of times.

ZZambia
In an ideal world, we should even trat all warning as errors (using -Werror). That's what I do whenever I can. It becomes hard when dealing with multiple platforms, but other than that, warning = error.
naixn
Yep, I do -Werror as well. My question was more for temporary code to aid debugging.
nall
Too bad you can't do this in a block. Doing it for rest of file is too dangerous for me.
sbwoodside