7.2 C++ compilation options
Most GCC options can be used for both C and C++ programs, but there are
also a few options which are specific to each language. This section
describes some of the additional options, and enhancements to existing
options, that are available in
When compiling with
g++, the options
-W include extra warnings specific to C++ (the warnings relate
to member functions and virtual classes). The use of these options is
always recommended while developing a program.
This option disables the default inlining of member functions defined in
the bodies of C++ classes. GCC normally inlines all such
functions when optimization is turned on, even if they do not explicitly
inline keyword. Select this option if you prefer to
control inlining yourself, or want to set a breakpoint on member
functions that would otherwise be inlined (since it is not possible to
set a breakpoint on an inlined function).
This option warns about C++ code which breaks some of the programming
guidelines given in the books "Effective C++" and "More
Effective C++" by Scott Meyers. For example, a warning will be given
if a class which uses dynamically allocated memory does not define a
copy constructor and an assignment operator. Note that the standard
library header files do not follow these guidelines, so you may wish to
use this option as an occasional test for possible problems in your own
code rather than compiling with it all the time.
This option highlights any uses of C-style casts in C++ programs. The
C++ language provides the keywords
const_cast for handling casts
and these are often preferable (although C-style casts are still allowed).