How do I disable warnings across versions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This code warns (incorrectly, but that's a whole separate issue):

double foo(double a, double b)
{
 bool option1_ok, option2_ok;
 double option1, option2;
 if (a == 0) {
   option1_ok = false;
 } else {
   option1 = b;
   option1_ok = true;
 }
 if (a == 1) {
   option2_ok = false;
 } else {
   option2 = b;
   option2_ok = true;
 }
 if (option1_ok) return option1;
 if (option2_ok) return option2;
 return 7;
}

Unfortunately, the bogus warning is -Wuninitialized in gcc 4.6 and
-Wmaybe-uninitialized in gcc 4.7.  The obvious way to silence the
warning is to wrap it in:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
...
#pragma GCC diagnostic pop

It silences the original warning, but now gcc 4.6 says:
warning: unknown option after ‘#pragma GCC diagnostic’ kind [-Wpragmas]

This seems to defeat the purpose, and adding
#pragma GCC diagnostic ignored "-Wpragmas"
is a little gross.  How am I supposed to do this?

Thanks,
Andy



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux