Boost logo

Boost :

Subject: Re: [boost] [Wiki] Changes in information about gcc warnings.
From: Patrick Horgan (phorgan1_at_[hidden])
Date: 2011-01-18 19:11:41

On 01/18/2011 01:10 PM, Stewart, Robert wrote:
> Patrick Horgan wrote:
>> On 01/18/2011 06:08 AM, Stewart, Robert wrote:
>>> -pedantic is a pain if you use, for example, #ident. So
>>> far as I know, there's no way to reduce the resulting noise.
>> That's true. Unfortunately there's no individual -W option for
>> complaining about #ident, so you can't turn off the warning.
> I wouldn't mind so much if the checks in -pedantic could be selected individually.
I couldn't agree with you more. The good news is that with each release
of gcc it seems, more of the warnings are individually controllable. Of
course the bad news is that boost supports older versions of the
compiler so you can't jump to things the way you want, for example the
wonderful scheme for suppressing warnings (if theres a -W argument for
them) is only really workable at 4.6.
>> If you're using #ident, which is a gcc extension, then you're
>> clearly making a choice to use that compiler and that
>> extension.
> Not quite. Other compilers support #ident, though it isn't standard. MSVC used to support an option with similar functionality, but no more. Now we just use:
> #ifndef _MSC_VER
> # ident "$Id:$"
> #endif
Annoying isn't it. It's the getting rid of a warning with an ifdef.
It's just not elegant.
>> In that case I wouldn't use -pedantic. Even something like
>> using -std=gnu++0x won't get rid of it. It's a perfectly
>> valid choice, but conflicts with a goal to be portable across
>> many compilers.
> That goal can be supported using conditional compilation, too. However, my point was that -pedantic may be something one uses occasionally to keep unwanted things at bay but may be too troublesome to be used all of the time. YMMV
That's valid. For boost right now it's not such a burden, but for some
code it certainly would be. It's good to know (to the extent the
compiler will really tell you) if you're doing things that don't adhere
to the spec.
>> Do you know what the default is for the version of gcc you're
>> using (currently c++98)?
> We're using the default, sadly, but that will change in the not too distant future.
Good. I built all of boost with ./bjam -a cxxflags="-Wall -Wextra
-pedantic -std=c++0x" and it wasn't so bad. There's a lot of warnings
but only a couple of failures.
>> As an example, there's a lot of usage of long long in boost,
>> which is not in c++98 and will give warnings in the absence of
>> -std=c++0x.
> We use -Wno-long-long to enable the use of long long.
That's a good way to cherry pick new things as they come up before
you're ready to move to a newer version of the standard. Luckily there
was a specific warning flag for this diagnostic.
> As Paul noted, such details should be included in the Wiki so they won't be a surprise.
I just added this to the wiki for pedantic:


    This instructs GCC to consider the release version of C or C++ and
    to first issue all warnings required by that version of the
    standard, and second warn about the use of gcc extenstions to the
    language. This would, for instance warn about the use of /#ident/
    since it is a gcc extension and is not in any of the standards.
    Using -pedantic makes it easier to write portable code, or at least
    to know when it is not. Best used with the /-std=xxxxx/ argument to
    the compiler, so that you know what version of the standard you're
    being compared to. Currently if /-std=xxxxx/ is not specified, it's
    as if you'd written /-std=gnu++98/. Much of boost uses facilities
    from more recent versions of the standard, so it might make more
    sense to explicitly specify /-std=c++0x/ or /-std=gnu++0x/.
    /-std=c++0x/ is most portable. See the page for more information.

What do you think?


Boost list run by bdawes at, gregod at, cpdaniel at, john at