Go to the previous, next section.
This section describes the command-line options that are only meaningful
for C++ programs; but you can also use most of the GNU compiler options
regardless of what language your program is in. For example, you
might compile a file firstClass.C like this:
g++ -g -felide-constructors -O -c firstClass.C
In this example, only `-felide-constructors' is an option meant only for C++ programs; you can use the other options with any language supported by GNU CC.
Here is a list of options that are only for compiling C++ programs:
-fall-virtual
new or
delete member operators) are treated as virtual functions of the
class where they appear.
This does not mean that all calls to these member functions will be made through the internal table of virtual 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
-felide-constructors
y directly from the call to foo without going
through a temporary in the following code:
A foo (); A y = foo ();
Without this option, GNU C++ (1) initializes y by calling the
appropriate constructor for type A; (2) assigns the result of
foo to a temporary; and, finally, (3) replaces the initial value of
y with the temporary.
The default behavior (`-fno-elide-constructors') is specified by the draft ANSI C++ standard. If your program's constructors have side effects, `-felide-constructors' can change your program's behavior, since some constructor calls may be omitted.
-fenum-int-equiv
int to enumeration types. Normally
GNU C++ allows conversion of enum to int, but not the
other way around.
-fexternal-templates
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
`-fno-external-templates', all template instantiations are
explicitly internal.
You do not need to specify `-fexternal-templates' when compiling a file that does not define and instantiate templates used in other files, even if your file uses templates defined in other files that are compiled with `-fexternal-templates'. The only side effect is an increase in object size for each file that you compile without `-fexternal-templates'.
-fmemoize-lookups
-fsave-memoized
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.
-fno-strict-prototype
foo takes no arguments.
-fnonnull-objects
Normally, GNU C++ makes conservative assumptions about objects reached
through references. For example, the compiler must check that a
is not null in code like the following:
obj &a = g (); a.f (2);
Checking that references of this sort have non-null values requires extra code, however, and it is unnecessary for many programs. You can use `-fnonnull-objects' to omit the checks for null, if your program doesn't require checking.
-fthis-is-variable
this. The incorporation of
user-defined free store management into C++ has made assignment to
`this' an anachronism. Therefore, by default it is invalid to
assign to this within a class member function; that is, GNU C++
treats the type of `this' in a member function of class X
to be `X *const'. However, for backwards compatibility, you can
make it valid with `-fthis-is-variable'.
-nostdinc++
-traditional
In addition, these optimization, warning, and code generation options have meanings only for C++ programs:
-fno-default-inline
-Wenum-clash
-Woverloaded-virtual
-Wtemplate-debugging
+en
cfront 1.x. See section Options for Code Generation Conventions.
Go to the previous, next section.