Next: Using the C++ standard library, Previous: Compiling a simple C++ program, Up: Compiling a C++ program
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 g++.
g++
, the options -Wall and
-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.
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).
static_cast
, dynamic_cast
,
reinterpret_cast
and const_cast
for handling casts
and these are often preferable (although C-style casts are still allowed).