Re: How do I disable warnings across versions?

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

 



On 15 May 2012 12:22, Vincent Lefevre <vincent+gcc@xxxxxxxxxx> wrote:
> On 2012-05-14 15:59:27 -0700, Andy Lutomirski wrote:
>> 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?
>
> I think that
>
> #pragma GCC diagnostic ignored "-Wpragmas"
>
> is exactly what you want. For instance,
>
> #pragma GCC diagnostic ignored "-Wpragmas"
> #pragma GCC diagnostic ignored "-Wuninitialized"
> #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
> #pragma GCC diagnostic ignored "-Wfoo"
> #pragma GCC diagnostic warning "-Wpragmas"
> #pragma GCC diagnostic ignored "-Wbar"
>
> will just give a warning concerning -Wbar.

And I think that in the same way we ignore -Wno-foo if no warnings are
given, we should ignore:

> #pragma GCC diagnostic ignored "-Wfoo"

Please open a PR.

Note that you can test for the exact version of GCC with #ifdef
GCC_MAJOR >= 4 && GCC_MINOR >= 7.

Cheers,

Manuel.



[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