-std's (was Re: v3 link failures analyzed)

Joseph S. Myers jsm28@cam.ac.uk
Wed Jan 10 14:16:00 GMT 2001


On 10 Jan 2001, Gabriel Dos Reis wrote:

> The matter isn't changing makefiles a decade.  It is about providing
> user-friendly and intuitive flags reflecting existing practices.  It
> is about providing a non-obscure flag reflecting the most stringent
> compliance to the most recent standard in use.  I don't find it

In that case, it is already necessary to use -pedantic in addition to the
-std option (though I hope that GCC will at some point provide a c99
executable that essentially does gcc -std=c99 -pedantic, and a
corresponding c89 executable).

> reasonable to require user to recall the exact spelling.  And I don't
> find it unreasonable to provide a flag select the most recent standard.
> Isn't it easier to teach that -iso selects both the most recent
> standards for C or C++ instead of insisting on different numbers?

Use of such options as -std=whatever and -pedantic is not a magic solution
for writing portable code, and we should not give the impression that it
is.  If someone is using an option to select strict conformance to a
standard where it conflicts with GNU, this should mean that they are
writing to the standard.  In particular, they have a copy of the standard
to hand, have read it completely, and have digested and understood its
technical content.  In this case, use of a particular -std option is a
precise technical statement to the compiler about their program.  The
standard number appears on every page of C99 apart from the inside back
cover and the spine.  It is hardly a value they are going to be unfamiliar
with, or at least have immediately to hand.  Such a (idealised)
programmer, presumably being conscientious, would surely not wish the
standard version the compiler interprets the code as to change, just
because a new edition of the standard has been released, until they have
carefully read and understood the new standard and considered how it might
affect the meaning of their code.  By contrast, an option meaning "the
latest standard", while possibly a useful shortcut for programmers who
know exactly what they're doing (including what standard that option means
with the version of the compiler they're using), and take proper care
about this when changing the version of the compiler in use, might be more
likely to be used by other programmers to feel good about being somehow
"portable", without concentrating the mind on that fact that they need to
read and understand a particular version of a complicated technical
document which they have told the compiler forms the contract between
implementation and program, their side of which they have agreed to follow
by writing code according to that standards document.

As for the name: -std exists to provide some regularity to names in this
area, and another -std name is better than another irregular option -iso
to add to the existing irregular -ansi, -pedantic and -traditional.

-- 
Joseph S. Myers
jsm28@cam.ac.uk



More information about the Libstdc++ mailing list