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:
-fno-access-control
-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.
-fcheck-new operator new is non-null before attempting to modify the storage allocated. The current Working Paper requires that operator new never return a null pointer, so this check is normally unnecessary.
-fconserve-space main() has completed, you may have an object that is being destroyed twice because two definitions were merged.
-fdollars-in-identifiers
-fenum-int-equiv int to enumeration types. Current C++ allows conversion of enum to int , but not the other way around.
-fexternal-templates
-falt-external-templates
-fno-gnu-keywords classof , headof , signature , sigof or typeof as a keyword, so that code can use these words as identifiers. You can use the keywords __classof__ , __headof__ , __signature__ , __sigof__ , and __typeof__ instead. `-ansi' implies `-fno-gnu-keywords'.
-fno-implicit-templates
-fhandle-signatures signature and sigof keywords for specifying abstract types. The default (`-fno-handle-signatures') is not to recognize them. See Type Abstraction using Signatures.
-fhuge-objects This flag is not useful when compiling with -fvtable-thunks.
-fno-implement-inlines
-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.
The code that implements these flags has rotted; you should probably avoid using them.
-fstrict-prototype foo can take any combination of arguments, as in C. `-pedantic' implies `-fstrict-prototype' unless overridden with `-fno-strict-prototype'. This flag no longer affects declarations with C++ linkage.
-fno-nonnull-objects At the moment, the compiler only does this checking for conversions to virtual base classes.
-foperator-names and , bitand , bitor , compl , not , or and xor as synonyms for the symbols they refer to. `-ansi' implies `-foperator-names'.
-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 `this' in a member function of class X as a non-lvalue of type `X *'. However, for backwards compatibility, you can make it valid with `-fthis-is-variable'.
-fvtable-thunks This option also enables a heuristic for controlling emission of vtables; if a class has any non-inline virtual functions, the vtable will be emitted in the translation unit containing the first one of those.
-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 Options for Code Generation Conventions.