
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Patrick Horgan Sent: Tuesday, January 11, 2011 12:05 AM To: boost@lists.boost.org Subject: [boost] [Wiki] Changes in information about gcc warnings.
I did a first cut at adding information to the wiki https://svn.boost.org/trac/boost/wiki/Guidelines/WarningsGuidelines for
changes in GCC that let you suppress warnings locally. It's probably not useful to you, since it's only in gcc version 4.x and the ability to push and pop
state is very recent, in 4.6. Nevertheless it needed documenting. There's a change to the behavior of #pragma GCC system_header as well. It previously had to be at file scope, and now can be anywhere in the file and affects from that point forward. The new pragma:
#pragma GCC diagnostic <ignored|warning|error> "- WASPECIFICWARNINGOPTION"
used like:
#pragma GCC diagnostic ignored "-Wdeprecated-declarations".
Prior to 4.6 this also had to be at file scope. As of 4.6 it can be at any line. With both it affects from that point forward.
#pragma GCC diagnostic <push|pop>
These two just showed up at 4.6 and can be at any line. Without them, the previous pragma is not that useful because if you affect the users flags
not like you! lol! With them you can do what you really want:
#pragma GCC diagnostic push #pragma GCC diagnostic "-Wunitialized" // your code here #pragma GCC diagnostic pop
4.6 is the current development trunk, so consider this a heads up. I'm
get from the gcc guys a good description of what preprocessor checks can be done to determine what's available when. When I get it, I'll add it to
the the current they will trying to the wiki.
Of course, almost all of the time warnings represent real issues and it's
better to
change your code to get rid of the warning and make it more correct, than to change your code to have ugly pragmas that suppress the warning.
Of course! Thanks for this - please do not hesitate to update the wiki with this valuable information. You might like to enquire of GCC if there is a limit on the number of push'n'pops - as we discovered with MSVC (which severely limits its usefulness as with Boost libraries it would be easy to exceed the limit (about 50). This limit increases the desirability of dealing the cause of the warnings, rather than silencing them). Paul PS We have little or no information about other platforms. Are spurious warnings a non-issue with them? --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com