Friday, February 27, 2009

GCC - Compiling a C++ program

C++ compilation options:
-Wall and -W: When compiling with g++, the options -Wall and -w include extra warnings specific to C++ (the warnings relate to member functions and virtual classes).
-fno-default-inline: disables the default inlining of member functions defined in the bodies of C++ classes. Select this option if you prefer to control inlining yourself, or want to set a breakpoint on member functions that would otherwise be inlined.
-Wold-style-cast: highlights any uses of C-style casts in C++ programs.

Templates:
[1] The executables created by g++ using the C++ standard library will be linked to the shared library 'libstdc++', which is supplied as part of the default GCC installation. There are several versions of this library -- if you distribute executables using the C++ standard library you need to ensure that the recipient has a compatible version of 'libstdc++', or link your program statically using the command-line option -static.
[2] The recommended way to use templates with g++ is to follow the inclusion compilation model, where template definitions are placed in header files. This is the method used by the C++ standard library supplied with GCC itself. If a template function is used several times in a program it will be stored in more than one objet file. The GNU Linker ensures that only one copy is placed in the final executable.
[3] Explicite template instantiation: template functions are no longer compiled at the point where they are used, as a result of the -fno-implicit-templates option.

Goto: http://www.network-theory.co.uk/docs/gccintro/gccintro_53.html

No comments: