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.
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 that point forward. At 4.6 and later it can be put at any line in
the file.
pragma GCC diagnostic <push|pop>
Not available until 4.6 and can be put at any point in the file.
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?
Patrick