John D Lamb
J.D.Lamb at btinternet.com
Sat Feb 13 07:16:02 UTC 2010
On Fri, 2010-02-12 at 13:58 -0700, Karl F. Larsen wrote:
> I have tried to understand man g++ which has 13680 lines of
> information. There are two basic types of g++ which are used
> in the USA. They are Standard C++ and ANSI/ISO Standard C++.
> Is there a way to change g++ so it uses either of those
> standards? In 10.04 I find it set for ANSI/ISO Standard C++
> and would like to change it.
AFAIK g++ without any options compiles by default against the 1998 ISO
standard C++ with some gnu extensions. This is equivalent to
$ g++ -std=gnu++98 …
If you want strict ISO standard, use
$ g++ -ansi …
$ g++ -std=c++98 …
There is also
$ g++ -std=c++0x …
for more recent versions of the standard. But note that g++ doesn’t yet
support (I think) support everything in every standard. I don’t think
any c++ compiler does. Typically you get some problems with some kinds
of template code.
If you’re looking for compatibility with other systems, -ansi might
help, though you might also want to use the -pedantic flag so that g++
gives errors rather than warnings. If you just want the compiler to stop
you writing poor code (e.g. functions that don’t return a value when the
should), the -pedantic and -Wall flags help.
More information about the ubuntu-users