Warning Supression Doesn't Work

Ian Lance Taylor iant@google.com
Fri May 23 02:08:00 GMT 2008


Lex Fridman <lexfridman@gmail.com> writes:

> What I've tried is to put one of the following in foo.cpp:
> #pragma GCC diagnostic ignored -Wunused
> #pragma GCC diagnostic warning -Wunused
> #pragma GCC diagnostic ignored "-Wunused"
> #pragma GCC diagnostic warning "-Wunused"

The last two are the right syntax.

> Do I need to have a later version of gcc than 4.1.3 for it to work? GCC
> simply says warning: ignoring #pragma GCC diagnostic

Yes, the feature is only available in gcc 4.2 and later.

Ian



More information about the Gcc-help mailing list