Re: How do I find when the diagnostic pragmas first came into gcc?

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


On 10 January 2011 23:44, Patrick Horgan wrote:
> On 01/10/2011 01:35 PM, Patrick Horgan wrote:
>>
>> I'm documenting the use of the diagnostic pragmas:
>>
>> |#pragma GCC diagnostic |kind option
>> |#pragma GCC diagnostic push|
>> |#pragma GCC diagnostic pop|
>>
>> on a boost page talking about how developers might deal with gcc warnings
>> and was wondering how to figure out what test I could put into a #if that
>> would avoid trying to use these pragmas in releases that did not support
>> them yet.
>>
>> Something like:
>>
>> #if defined(__GNUC__)
>> #pragma GCC diagnostic push
>> #pragma GCC diagnostic ignored "-Wformat"
>> #endif
>>
>> // code here that generates a spurious warning controlled by -Wformat
>>
>> #if defined(__GNUC__)
>> #pragma GCC diagnostic pop
>> #endif
>
> My understanding is that:
> pragma GCC system_header
> is usable for releases 4 and greater, but that prior to 4.6, it had to be at
> file scope and then affected from that point forward.  At 4.6 and later it
> will be able to be inserted anywhere in the file.

It's worked since 3.0, maybe earlier.
I don't know of any change in semantics in 4.6, but I might have
missed something.

> pragma GCC diagnostic <warning|error|ignored> "-WSOMETYPEOFWARNING"
> is usable at 4.1 or 4.2? and had to be put at file scope and affected from

4.2

> that point forward.  At 4.6 and later it can be put at any line in the file.

I think that's right.

> pragma GCC diagnostic <push|pop>
> Not available until 4.6 and can be put at any point in the file.

Right.

> Is all that right?
>
> So what preprocessor tests can be used so that with -Wall which turns on
> -Wunknown-pragma I won't get warnings about unknown pragmas?

 __GNUC__ and __GNUC_MINOR__
http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html



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

Add to Google