C++ source files use one of the suffixes `.C', `.cc', or `.cxx'.
Options must be separate: `-dr' is quite different from `-d -r '.
Most `-f' and `-W' options have two contrary forms: -fname and -fno-name (or -Wname and -Wno-name). Only the non-default forms are shown here.
With `+e0', virtual function definitions in classes are declared extern; the declaration is used only as an interface specification, not to generate code for the virtual functions (in this compilation).
With `+e1', g++ actually generates the code implementing virtual functions defined in the code, and makes them publicly visible.
This does not mean that all calls to these methods will be made through the internal table of virtual functions. There are some circumstances under which it is obvious that a call to a given virtual function can be made directly, and in these cases the calls still go direct.
The effect of making all methods of a class with a declared `operator->()()' implicitly virtual using `-fall-virtual' extends also to all non-constructor methods of any class derived from such a class.
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++ initializes `y' directly from the call to foo () without going through a temporary.
With `-fno-gnu-binutils', you must use the program collect (part of the GCC distribution) for linking.
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 function 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 compiler determines that the context of the last function 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 functions for the same class: with the exception of member functions which are friends of other classes, each member function has exactly the same access privileges as every other, and the cache need not be flushed.
Unlike most other C compilers, GNU CC allows you to use `-g' with `-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without `-O', only variables declared register are allocated in registers. The resulting compiled code is a little worse than produced by PCC without `-O'.
With `-O', the compiler tries to reduce code size and execution time.
Specifically, for both C and C++ programs:
For C++ programs only (not C), `-traditional' has one additional effect: assignment to this is permitted. This is the same as the effect of `-fthis-is-variable'.
If you use `#pragma implementation' with no argument, it applies to an include file with the same basename as your source file; for example, in `allclass.cc', `#pragma implementation' by itself is equivalent to `#pragma implementation "allclass.h"'. Use the string argument if you want a single implementation file to include code from multiple header files.
There is no way to split up the contents of a single header file into multiple implementation files.
LIBDIR
is usually
/usr/local/lib/machine/version.
TMPDIR
comes from the environment variable
TMPDIR
(default
/usr/tmp
if available, else
/tmp).
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.