home *** CD-ROM | disk | FTP | other *** search
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- NNAAMMEE
- g++ - GNU project C++ Compiler (v2 preliminary)
-
- SSYYNNOOPPSSIISS
- g++ [[_o_p_t_i_o_n | _f_i_l_e_n_a_m_e ]...
-
- DDEESSCCRRIIPPTTIIOONN
- The C and C++ compilers are integrated; gg++++ is a script to
- call ggcccc wwiitthh ooppttiioonnss ttoo rreeccooggnniizzee CC++++.. ggcccc processes
- input files through one or more of four stages: prepro-
- cessing, compilation, assembly, and linking. This man
- page contains full descriptions for _o_n_l_y C++ specific
- aspects of the compiler, though it also contains summaries
- of some general-purpose options. For a fuller explanation
- of the compiler, see ggcccc(11).
-
- C++ source files use one of the suffixes `..CC', `..cccc', or
- `..ccxxxx'; preprocessed C++ files use the suffix `..iiii'.
-
- OOPPTTIIOONNSS
- There are many command-line options, including options to
- control details of optimization, warnings, and code gener-
- ation, which are common to both ggcccc and gg++++. For full
- information on all options, see ggcccc(11).
-
- Options must be separate: `--ddrr' is quite different from
- `--dd --rr '.
-
- Most `--ff' and `--WW' options have two contrary forms: --ff_n_a_m_e
- and --ffnnoo--_n_a_m_e (or --WW_n_a_m_e and --WWnnoo--_n_a_m_e). Only the non-
- default forms are shown here.
-
-
- --cc Compile or assemble the source files, but do not
- link. The compiler output is an object file corre-
- sponding to each source file.
-
- --DD_m_a_c_r_o
- Define macro _m_a_c_r_o with the string `11' as its defi-
- nition.
-
- --DD_m_a_c_r_o==_d_e_f_n
- Define macro _m_a_c_r_o as _d_e_f_n.
-
- --EE Stop after the preprocessing stage; do not run the
- compiler proper. The output is preprocessed source
- code, which is sent to the standard output.
-
- ++ee_N control whether virtual function definitions in
- classes are used to generate code, or only to
- define interfaces for their callers. These options
- are provided for compatibility with cfront 1.x
- usage; the recommended GNU C++ usage is to use
- ##pprraaggmmaa iinntteerrffaaccee and ##pprraaggmmaa iimmpplleemmeennttaattiioonn,
-
-
-
- GNU Tools 27dec1991 1
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- instead.
-
- With `++ee00', virtual function definitions in classes
- are declared extern; the declaration is used only
- as an interface specification, not to generate code
- for the virtual functions (in this compilation).
-
- With `++ee11', gg++++ actually generates the code imple-
- menting virtual functions defined in the code, and
- makes them publicly visible.
-
- --ffaallll--vviirrttuuaall
- When you use the `--ffaallll--vviirrttuuaall', all member func-
- tions (except for constructor functions and
- new/delete member operators) declared in the same
- class with a ``method-call'' operator method are
- treated as virtual functions of the given class.
- In effect, all of these methods become ``implicitly
- virtual.''
-
- This does _n_o_t mean that all calls to these methods
- will be made through the internal table of virtual
- functions. There are some circumstances under
- which it is obvious that a call to a given virtual
- function can be made directly, and in these cases
- the calls still go direct.
-
- The effect of making all methods of a class with a
- declared `ooppeerraattoorr-->>(())(())' implicitly virtual using
- `--ffaallll--vviirrttuuaall' extends also to all non-constructor
- methods of any class derived from such a class.
-
- --ffddoollllaarrss--iinn--iiddeennttiiffiieerrss
- Permit the use of `$$' in identifiers. Traditional
- C allowed the character `$$' to form part of identi-
- fiers; by default, GNU C also allows this. How-
- ever, ANSI C forbids `$$' in identifiers, and GNU
- C++ also forbids it by default on most platforms
- (though on some platforms it's enabled by default
- for GNU C++ as well).
-
- --ffeelliiddee--ccoonnssttrruuccttoorrss
- Use this option to instruct the compiler to be
- smarter about when it can elide constructors.
- Without this flag, GNU C++ and cfront both generate
- effectively the same code for:
-
- A foo ();
- A x (foo ()); // x initialized by `foo ()', no ctor called
- A y = foo (); // call to `foo ()' heads to tempo-
- rary,
- // y is initialized from the tempo-
- rary.
-
-
-
-
- GNU Tools 27dec1991 2
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- Note the difference! With this flag, GNU C++ ini-
- tializes `yy' directly from the call to ffoooo (()) with-
- out going through a temporary.
-
- --ffeennuumm--iinntt--eeqquuiivv
- Normally GNU C++ allows conversion of eennuumm to iinntt,
- but not the other way around. Use this option if
- you want GNU C++ to allow conversion of iinntt to eennuumm
- as well.
-
- --ffggnnuu--bbiinnuuttiillss
-
- --ffnnoo--ggnnuu--bbiinnuuttiillss
- `--ffggnnuu--bbiinnuuttiillss ' (the default for most, but not
- all, platforms) makes GNU C++ emit extra informa-
- tion for static initialization and finalization.
- This information has to be passed from the assem-
- bler to the GNU linker. Some assemblers won't pass
- this information; you must either use GNU aass or
- specify the option `--ffnnoo--ggnnuu--bbiinnuuttiillss'.
-
- With `--ffnnoo--ggnnuu--bbiinnuuttiillss', you must use the program
- ccoolllleecctt (part of the GCC distribution) for linking.
-
- --ffmmeemmooiizzee--llooookkuuppss
-
- --ffssaavvee--mmeemmooiizzeedd
- These flags are used to get the compiler to compile
- programs faster using heuristics. They are not on
- by default since they are only effective about half
- the time. The other half of the time programs com-
- pile more slowly (and take more memory).
-
- 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 intro-
- duces another layer of mechanisms which must be
- implemented, and so incurs its own overhead.
-
-
-
- GNU Tools 27dec1991 3
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- `--ffmmeemmooiizzee--llooookkuuppss' enables the software cache.
-
- Because access privileges (visibility) to members
- and member functions may differ from one function
- context to the next, gg++++ may need to flush the
- cache. With the `--ffmmeemmooiizzee--llooookkuuppss' flag, the cache
- is flushed after every function that is compiled.
- The `-fsave-memoized' flag enables the same soft-
- ware cache, but when the compiler determines that
- the context of the last function compiled would
- yield the same access privileges of the next func-
- tion 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 privi-
- leges as every other, and the cache need not be
- flushed.
-
- --ffnnoo--ddeeffaauulltt--iinnlliinnee
- If `--ffddeeffaauulltt--iinnlliinnee' is enabled then member func-
- tions defined inside class scope are compiled
- inline by default; i.e., you don't need to add
- `iinnlliinnee' in front of the member function name. By
- popular demand, this option is now the default. To
- keep GNU C++ from inlining these member functions,
- specify `--ffnnoo--ddeeffaauulltt--iinnlliinnee'.
-
- --ffnnoo--ssttrriicctt--pprroottoottyyppee
- Consider the declaration iinntt ffoooo (());;. In C++, this
- means that the function ffoooo takes no arguments. In
- ANSI C, this is declared iinntt ffoooo((vvooiidd));;. With the
- flag `--ffnnoo--ssttrriicctt--pprroottoottyyppee', declaring functions
- with no arguments is equivalent to declaring its
- argument list to be untyped, i.e., iinntt ffoooo (());; is
- equivalent to saying iinntt ffoooo ((......));;.
-
- --ffnnoonnnnuullll--oobbjjeeccttss
- Normally, GNU C++ makes conservative assumptions
- about objects reached through references. For
- example, the compiler must check that `aa' 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
- `--ffnnoonnnnuullll--oobbjjeeccttss' to omit the checks for null, if
- your program doesn't require the default checking.
-
- --fftthhiiss--iiss--vvaarriiaabbllee
- The incorporation of user-defined free store man-
- agement into C++ has made assignment to tthhiiss an
- anachronism. Therefore, by default GNU C++ treats
-
-
-
- GNU Tools 27dec1991 4
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- the type of tthhiiss in a member function of ccllaassss XX to
- be XX **ccoonnsstt. In other words, it is illegal to
- assign to tthhiiss within a class member function.
- However, for backwards compatibility, you can
- invoke the old behavior by using
- `--fftthhiiss--iiss--vvaarriiaabbllee'.
-
- --gg Produce debugging information in the operating sys-
- tem's native format (for DBX or SDB or DWARF). GDB
- also can work with this debugging information. On
- most systems that use DBX format, `--gg' enables use
- of extra debugging information that only GDB can
- use.
-
- Unlike most other C compilers, GNU CC allows you to
- use `--gg' with `--OO'. The shortcuts taken by opti-
- mized code may occasionally produce surprising
- results: some variables you declared may not exist
- at all; flow of control may briefly move where you
- did not expect it; some statements may not be exe-
- cuted because they compute constant results or
- their values were already at hand; some statements
- may execute in different places because they were
- moved out of loops.
-
- Nevertheless it proves possible to debug optimized
- output. This makes it reasonable to use the opti-
- mizer for programs that might have bugs.
-
- --II_d_i_r Append directory _d_i_r to the list of directories
- searched for include files.
-
- --LL_d_i_r Add directory _d_i_r to the list of directories to be
- searched for `--ll'.
-
- --ll_l_i_b_r_a_r_y
- Use the library named _l_i_b_r_a_r_y when linking. (C++
- programs often require `-lg++' for successful link-
- ing.)
-
- --OO Optimize. Optimizing compilation takes somewhat
- more time, and a lot more memory for a large func-
- tion.
-
- Without `--OO', the compiler's goal is to reduce the
- cost of compilation and to make debugging produce
- the expected results. Statements are independent:
- if you stop the program with a breakpoint between
- statements, you can then assign a new value to any
- variable or change the program counter to any other
- statement in the function and get exactly the
- results you would expect from the source code.
-
- Without `--OO', only variables declared rreeggiisstteerr are
-
-
-
- GNU Tools 27dec1991 5
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- allocated in registers. The resulting compiled
- code is a little worse than produced by PCC without
- `--OO'.
-
- With `--OO', the compiler tries to reduce code size
- and execution time.
-
- --oo _f_i_l_e
- Place output in file _f_i_l_e.
-
- --SS Stop after the stage of compilation proper; do not
- assemble. The output is an assembler code file for
- each non-assembler input file specified.
-
- --ssttaattiicc
- On systems that support dynamic linking, this pre-
- vents linking with the shared libraries. On other
- systems, this option has no effect.
-
- --ttrraaddiittiioonnaall
- Attempt to support some aspects of traditional C
- compilers.
-
- Specifically, for both C and C++ programs:
-
- o In the preprocessor, comments convert to nothing at
- all, rather than to a space. This allows tradi-
- tional token concatenation.
-
- o In the preprocessor, macro arguments are recognized
- within string constants in a macro definition (and
- their values are stringified, though without addi-
- tional quote marks, when they appear in such a con-
- text). The preprocessor always considers a string
- constant to end at a newline.
-
- o The preprocessor does not predefine the macro
- ____SSTTDDCC____ when you use `--ttrraaddiittiioonnaall', but still
- predefines____GGNNUUCC____ (since the GNU extensions indi-
- cated by ____GGNNUUCC____ are not affected by
- `--ttrraaddiittiioonnaall'). If you need to write header files
- that work differently depending on whether
- `--ttrraaddiittiioonnaall' is in use, by testing both of these
- predefined macros you can distinguish four situa-
- tions: GNU C, traditional GNU C, other ANSI C com-
- pilers, and other old C compilers.
-
- o In the preprocessor, comments convert to nothing at
- all, rather than to a space. This allows tradi-
- tional token concatenation.
-
- o In the preprocessor, macro arguments are recognized
- within string constants in a macro definition (and
- their values are stringified, though without
-
-
-
- GNU Tools 27dec1991 6
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- additional quote marks, when they appear in such a
- context). The preprocessor always considers a
- string constant to end at a newline.
-
- o The preprocessor does not predefine the macro
- ____SSTTDDCC____ when you use `--ttrraaddiittiioonnaall', but still
- predefines____GGNNUUCC____ (since the GNU extensions indi-
- cated by ____GGNNUUCC____ are not affected by
- `--ttrraaddiittiioonnaall'). If you need to write header files
- that work differently depending on whether
- `--ttrraaddiittiioonnaall' is in use, by testing both of these
- predefined macros you can distinguish four situa-
- tions: GNU C, traditional GNU C, other ANSI C com-
- pilers, and other old C compilers.
-
-
- o String ``constants'' are not necessarily constant;
- they are stored in writable space, and identical
- looking constants are allocated separately. (This
- is the same as the effect of `--ffwwrriittaabbllee--ssttrriinnggss'.)
-
- For C++ programs only (not C), `--ttrraaddiittiioonnaall' has
- one additional effect: assignment to tthhiiss is per-
- mitted. This is the same as the effect of
- `--fftthhiiss--iiss--vvaarriiaabbllee'.
-
- --UU_m_a_c_r_o
- Undefine macro _m_a_c_r_o.
-
- --WWaallll Issue warnings for conditions which pertain to
- usage that we recommend avoiding and that we
- believe is easy to avoid, even in conjunction with
- macros.
-
- --WWeennuumm--ccllaasshh
- Warn when converting between different enumeration
- types.
-
- --WWoovveerrllooaaddeedd--vviirrttuuaall
- In a derived class, the definitions of virtual
- functions must match the type signature of a vir-
- tual function declared in the base class. Use this
- option to request warnings when a derived class
- declares a function that may be an erroneous
- attempt to define a virtual function: that is, warn
- when a function with the same name as a virtual
- function in the base class, but with a type signa-
- ture that doesn't match any virtual functions from
- the base class.
-
- --ww Inhibit all warning messages.
-
-
-
-
-
-
- GNU Tools 27dec1991 7
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- PPRRAAGGMMAASS
- Two `##pprraaggmmaa' directives are supported for GNU C++, to
- permit using the same header file for two purposes: as a
- definition of interfaces to a given object class, and as
- the full definition of the contents of that object class.
-
- ##pprraaggmmaa iinntteerrffaaccee
- Use this directive in header files that define
- object classes, to save space in most of the object
- files that use those classes. Normally, local
- copies of certain information (backup copies of
- inline member functions, debugging information, and
- the internal tables that implement virtual func-
- tions) must be kept in each object file that
- includes class definitions. You can use this
- pragma to avoid such duplication. When a header
- file containing `##pprraaggmmaa iinntteerrffaaccee' is included in
- a compilation, this auxiliary information will not
- be generated (unless the main input source file
- itself uses `##pprraaggmmaa iimmpplleemmeennttaattiioonn'). Instead,
- the object files will contain references to be
- resolved at link time.
-
- ##pprraaggmmaa iimmpplleemmeennttaattiioonn
-
- ##pprraaggmmaa iimmpplleemmeennttaattiioonn ""_o_b_j_e_c_t_s..hh""
- Use this pragma in a main input file, when you want
- full output from included header files to be gener-
- ated (and made globally visible). The included
- header file, in turn, should use `##pprraaggmmaa
- iinntteerrffaaccee'. Backup copies of inline member func-
- tions, debugging information, and the internal
- tables used to implement virtual functions are all
- generated in implementation files.
-
- If you use `##pprraaggmmaa iimmpplleemmeennttaattiioonn' with no argu-
- ment, it applies to an include file with the same
- basename as your source file; for example, in
- `aallllccllaassss..cccc', `##pprraaggmmaa iimmpplleemmeennttaattiioonn' by itself
- is equivalent to `##pprraaggmmaa iimmpplleemmeennttaattiioonn
- ""aallllccllaassss..hh""'. Use the string argument if you want
- a single implementation file to include code from
- multiple header files.
-
- There is no way to split up the contents of a sin-
- gle header file into multiple implementation files.
-
- FFIILLEESS
- file.h C header (preprocessor) file
- file.i preprocessed C source file
- file.C C++ source file
- file.cc C++ source file
- file.cxx C++ source file
- file.s assembly language file
-
-
-
- GNU Tools 27dec1991 8
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- file.o object file
- a.out link edited output
- _T_M_P_D_I_R/cc* temporary files
- _L_I_B_D_I_R/cpp preprocessor
- _L_I_B_D_I_R/cc1plus compiler
- _L_I_B_D_I_R/collect linker front end needed on some
- machines
- _L_I_B_D_I_R/libgcc.a GCC subroutine library
- /lib/crt[01n].o start-up routine
- _L_I_B_D_I_R/ccrt0 additional start-up routine for C++
- /lib/libc.a standard C library, see _i_n_t_r_o(3)
- /usr/include standard directory for ##iinncclluuddee files
- _L_I_B_D_I_R/include standard gcc directory for ##iinncclluuddee
- files
- _L_I_B_D_I_R/g++-include additional g++ directory for ##iinncclluuddee
-
- _L_I_B_D_I_R is usually //uussrr//llooccaall//lliibb//_m_a_c_h_i_n_e/_v_e_r_s_i_o_n.
- _T_M_P_D_I_R comes from the environment variable TTMMPPDDIIRR (default
- //uussrr//ttmmpp if available, else //ttmmpp).
-
- SSEEEE AALLSSOO
- gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1),
- sdb(1).
- `ggcccc', `ccpppp', `aass',``ld'',, and `ggddbb' entries in iinnffoo.
- _U_s_i_n_g _a_n_d _P_o_r_t_i_n_g _G_N_U _C_C _(_f_o_r _v_e_r_s_i_o_n _2_._0_), Richard M.
- Stallman, November 1990; _T_h_e _C _P_r_e_p_r_o_c_e_s_s_o_r, Richard M.
- Stallman, July 1990; _U_s_i_n_g _G_D_B_: _A _G_u_i_d_e _t_o _t_h_e _G_N_U _S_o_u_r_c_e_-
- _L_e_v_e_l _D_e_b_u_g_g_e_r, Richard M. Stallman and Roland H. Pesch,
- December 1991; _U_s_i_n_g _a_s_: _t_h_e _G_N_U _A_s_s_e_m_b_l_e_r, Dean Elsner,
- Jay Fenlason & friends, March 1991; _g_l_d_: _t_h_e _G_N_U _l_i_n_k_e_r,
- Steve Chamberlain and Roland Pesch, April 1991.
-
-
- BBUUGGSS
- Report bugs to bbuugg--gg++++@@pprreepp..aaii..mmiitt..eedduu. Bugs tend actu-
- ally to be fixed if they can be isolated, so it is in your
- interest to report them in such a way that they can be
- easily reproduced.
-
- CCOOPPYYIINNGG
- Copyright (c) 1991 Free Software Foundation, Inc.
-
- Permission is granted to make and distribute verbatim
- copies of this manual provided the copyright notice and
- this permission notice are preserved on all copies.
-
- Permission is granted to copy and distribute modified ver-
- sions of this manual under the conditions for verbatim
- copying, provided that the entire resulting derived work
- is distributed under the terms of a permission notice
- identical to this one.
-
- Permission is granted to copy and distribute translations
- of this manual into another language, under the above
-
-
-
- GNU Tools 27dec1991 9
-
-
-
-
-
- G++(1) GNU Tools G++(1)
-
-
- conditions for modified versions, except that this permis-
- sion notice may be included in translations approved by
- the Free Software Foundation instead of in the original
- English.
-
- AAUUTTHHOORRSS
- See the GNU CC Manual for the contributors to GNU CC.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- GNU Tools 27dec1991 10
-
-
-