home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
gnu
/
gcc-2.6.3-bin.lha
/
GNU
/
man
/
cat1
/
g++.0
< prev
next >
Wrap
Text File
|
1994-02-08
|
23KB
|
595 lines
G++(1) GNU Tools G++(1)
NAME
g++ - GNU project C++ Compiler (v2.4)
SYNOPSIS
g++ [_o_p_t_i_o_n | _f_i_l_e_n_a_m_e ]...
DESCRIPTION
The C and C++ compilers are integrated; g++ is a script to
call gcc with options to recognize C++. gcc processes input
files through one or more of four stages: preprocessing,
compilation, assembly, and linking. This man page contains
full descriptions for _o_n_l_y C++ specific aspects of the com-
piler, though it also contains summaries of some general-
purpose options. For a fuller explanation of the compiler,
see gcc(1).
C++ source files use one of the suffixes `.C', `.cc', or
`.cxx'; preprocessed C++ files use the suffix `.ii'.
OPTIONS
There are many command-line options, including options to
control details of optimization, warnings, and code genera-
tion, which are common to both gcc and g++. For full infor-
mation on all options, see gcc(1).
Options must be separate: `-dr' is quite different from `-d
-r '.
Most `-f' and `-W' options have two contrary forms: -f_n_a_m_e
and -fno-_n_a_m_e (or -W_n_a_m_e and -Wno-_n_a_m_e). Only the non-
default forms are shown here.
-c Compile or assemble the source files, but do not link.
The compiler output is an object file corresponding to
each source file.
-D_m_a_c_r_o
Define macro _m_a_c_r_o with the string `1' as its defini-
tion.
-D_m_a_c_r_o=_d_e_f_n
Define macro _m_a_c_r_o as _d_e_f_n.
-E Stop after the preprocessing stage; do not run the com-
piler proper. The output is preprocessed source code,
which is sent to the standard output.
-fall-virtual
Treat all possible member functions as virtual, impli-
citly. All member functions (except for constructor
functions and new or delete member operators) are
GNU Tools Last change: 30apr1993 1
G++(1) GNU Tools G++(1)
treated as virtual functions of the class where they
appear.
This does not mean that all calls to these member func-
tions will be made through the internal table of vir-
tual functions. Under some circumstances, the compiler
can determine that a call to a given virtual function
can be made directly; in these cases the calls are
direct in any case.
-fdollars-in-identifiers
Permit the use of `$' in identifiers. Traditional C
allowed the character `$' to form part of identifiers;
by default, GNU C also allows this. However, ANSI C
forbids `$' in identifiers, and GNU C++ also forbids it
by default on most platforms (though on some platforms
it's enabled by default for GNU C++ as well).
-felide-constructors
Use this option to instruct the compiler to be smarter
about when it can elide constructors. Without this
flag, GNU C++ and cfront both generate effectively the
same code for:
A foo ();
A x (foo ()); // x initialized by `foo ()', no ctor called
A y = foo (); // call to `foo ()' heads to temporary,
// y is initialized from the temporary.
Note the difference! With this flag, GNU C++ initial-
izes `y' directly from the call to foo () without going
through a temporary.
-fenum-int-equiv
Normally GNU C++ allows conversion of enum to int, but
not the other way around. Use this option if you want
GNU C++ to allow conversion of int to enum as well.
-fexternal-templates
Produce smaller code for template declarations, by gen-
erating only a single copy of each template function
where it is defined. To use this option successfully,
you must also mark all files that use templates with
either `#pragma implementation' (the definition) or
`#pragma interface' (declarations).
When your code is compiled with `-fexternal-templates',
all template instantiations are external. You must
arrange for all necessary instantiations to appear in
the implementation file; you can do this with a typedef
that references each instantiation needed. Conversely,
when you compile using the default option
GNU Tools Last change: 30apr1993 2
G++(1) GNU Tools G++(1)
`-fno-external-templates', all template instantiations
are explicitly internal.
-fno-gnu-linker
Do not output global initializations (such as C++ con-
structors and destructors) in the form used by the GNU
linker (on systems where the GNU linker is the standard
method of handling them). Use this option when you
want to use a non-GNU linker, which also requires using
the collect2 program to make sure the system linker
includes constructors and destructors. (collect2 is
included in the GNU CC distribution.) For systems
which _m_u_s_t use collect2, the compiler driver gcc is
configured to do this automatically.
-fmemoize-lookups
-fsave-memoized
These flags are used to get the compiler to compile
programs faster using heuristics. They are not on by
default since they are only effective about half the
time. The other half of the time programs compile more
slowly (and take more memory).
The first time the compiler must build a call to a
member function (or reference to a data member), it
must (1) determine whether the class implements member
functions of that name; (2) resolve which member func-
tion to call (which involves figuring out what sorts of
type conversions need to be made); and (3) check the
visibility of the member function to the caller. All
of this adds up to slower compilation. Normally, the
second time a call is made to that member function (or
reference to that data member), it must go through the
same lengthy process again. This means that code like
this
cout << "This " << p << " has " << n << " legs.\n";
makes six passes through all three steps. By using a
software cache, a ``hit'' significantly reduces this
cost. Unfortunately, using the cache introduces
another layer of mechanisms which must be implemented,
and so incurs its own overhead. `-fmemoize-lookups'
enables the software cache.
Because access privileges (visibility) to members and
member functions may differ from one function context
to the next, g++ may need to flush the cache. With the
`-fmemoize-lookups' flag, the cache is flushed after
every function that is compiled. The `-fsave-memoized'
flag enables the same software cache, but when the
GNU Tools Last change: 30apr1993 3
G++(1) GNU Tools G++(1)
compiler determines that the context of the last func-
tion compiled would yield the same access privileges of
the next function to compile, it preserves the cache.
This is most helpful when defining many member func-
tions for the same class: with the exception of member
functions which are friends of other classes, each
member function has exactly th