home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / gnu / man / cat1 / g++.0 < prev    next >
Text File  |  1994-02-08  |  23KB  |  595 lines

  1.  
  2.  
  3.  
  4. G++(1)                      GNU Tools                      G++(1)
  5.  
  6.  
  7.  
  8. NAME
  9.      g++ - GNU project C++ Compiler (v2.4)
  10.  
  11. SYNOPSIS
  12.      g++ [_o_p_t_i_o_n | _f_i_l_e_n_a_m_e ]...
  13.  
  14. DESCRIPTION
  15.      The C and C++ compilers are integrated; g++ is a  script  to
  16.      call gcc with options to recognize C++.  gcc processes input
  17.      files through one or more  of  four  stages:  preprocessing,
  18.      compilation,  assembly, and linking.  This man page contains
  19.      full descriptions for _o_n_l_y C++ specific aspects of the  com-
  20.      piler,  though  it  also contains summaries of some general-
  21.      purpose options.  For a fuller explanation of the  compiler,
  22.      see gcc(1).
  23.  
  24.      C++ source files use one of the  suffixes  `.C',  `.cc',  or
  25.      `.cxx'; preprocessed C++ files use the suffix `.ii'.
  26.  
  27. OPTIONS
  28.      There are many command-line options,  including  options  to
  29.      control  details of optimization, warnings, and code genera-
  30.      tion, which are common to both gcc and g++.  For full infor-
  31.      mation on all options, see gcc(1).
  32.  
  33.      Options must be separate: `-dr' is quite different from  `-d
  34.      -r '.
  35.  
  36.      Most `-f' and `-W' options have two contrary  forms:  -f_n_a_m_e
  37.      and  -fno-_n_a_m_e  (or  -W_n_a_m_e  and  -Wno-_n_a_m_e).  Only the non-
  38.      default forms are shown here.
  39.  
  40.  
  41.      -c   Compile or assemble the source files, but do not  link.
  42.           The  compiler output is an object file corresponding to
  43.           each source file.
  44.  
  45.      -D_m_a_c_r_o
  46.           Define macro _m_a_c_r_o with the string `1' as  its  defini-
  47.           tion.
  48.  
  49.      -D_m_a_c_r_o=_d_e_f_n
  50.           Define macro _m_a_c_r_o as _d_e_f_n.
  51.  
  52.      -E   Stop after the preprocessing stage; do not run the com-
  53.           piler  proper.  The output is preprocessed source code,
  54.           which is sent to the standard output.
  55.  
  56.      -fall-virtual
  57.           Treat all possible member functions as virtual,  impli-
  58.           citly.   All  member  functions (except for constructor
  59.           functions and  new  or  delete  member  operators)  are
  60.  
  61.  
  62.  
  63. GNU Tools            Last change: 30apr1993                     1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. G++(1)                      GNU Tools                      G++(1)
  71.  
  72.  
  73.  
  74.           treated  as  virtual  functions of the class where they
  75.           appear.
  76.  
  77.           This does not mean that all calls to these member func-
  78.           tions  will  be made through the internal table of vir-
  79.           tual functions.  Under some circumstances, the compiler
  80.           can  determine  that a call to a given virtual function
  81.           can be made directly; in  these  cases  the  calls  are
  82.           direct in any case.
  83.  
  84.      -fdollars-in-identifiers
  85.           Permit the use of `$' in  identifiers.   Traditional  C
  86.           allowed  the character `$' to form part of identifiers;
  87.           by default, GNU C also allows this.   However,  ANSI  C
  88.           forbids `$' in identifiers, and GNU C++ also forbids it
  89.           by default on most platforms (though on some  platforms
  90.           it's enabled by default for GNU C++ as well).
  91.  
  92.      -felide-constructors
  93.           Use this option to instruct the compiler to be  smarter
  94.           about  when  it  can  elide constructors.  Without this
  95.           flag, GNU C++ and cfront both generate effectively  the
  96.           same code for:
  97.  
  98.           A foo ();
  99.           A x (foo ());   // x initialized by `foo ()', no ctor called
  100.           A y = foo ();   // call to `foo ()' heads to temporary,
  101.                           // y is initialized from the temporary.
  102.  
  103.           Note the difference!  With this flag, GNU C++  initial-
  104.           izes `y' directly from the call to foo () without going
  105.           through a temporary.
  106.  
  107.      -fenum-int-equiv
  108.           Normally GNU C++ allows conversion of enum to int,  but
  109.           not  the other way around.  Use this option if you want
  110.           GNU C++ to allow conversion of int to enum as well.
  111.  
  112.      -fexternal-templates
  113.           Produce smaller code for template declarations, by gen-
  114.           erating  only  a  single copy of each template function
  115.           where it is defined.  To use this option  successfully,
  116.           you  must  also  mark all files that use templates with
  117.           either `#pragma  implementation'  (the  definition)  or
  118.           `#pragma interface' (declarations).
  119.  
  120.           When your code is compiled with `-fexternal-templates',
  121.           all  template  instantiations  are  external.  You must
  122.           arrange for all necessary instantiations to  appear  in
  123.           the implementation file; you can do this with a typedef
  124.           that references each instantiation needed.  Conversely,
  125.           when    you    compile   using   the   default   option
  126.  
  127.  
  128.  
  129. GNU Tools            Last change: 30apr1993                     2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. G++(1)                      GNU Tools                      G++(1)
  137.  
  138.  
  139.  
  140.           `-fno-external-templates', all template  instantiations
  141.           are explicitly internal.
  142.  
  143.      -fno-gnu-linker
  144.           Do not output global initializations (such as C++  con-
  145.           structors  and destructors) in the form used by the GNU
  146.           linker (on systems where the GNU linker is the standard
  147.           method  of  handling  them).   Use this option when you
  148.           want to use a non-GNU linker, which also requires using
  149.           the  collect2  program  to  make sure the system linker
  150.           includes constructors and  destructors.   (collect2  is
  151.           included  in  the  GNU  CC  distribution.)  For systems
  152.           which _m_u_s_t use collect2, the  compiler  driver  gcc  is
  153.           configured to do this automatically.
  154.  
  155.      -fmemoize-lookups
  156.  
  157.      -fsave-memoized
  158.           These flags are used to get  the  compiler  to  compile
  159.           programs  faster  using heuristics.  They are not on by
  160.           default since they are only effective  about  half  the
  161.           time.  The other half of the time programs compile more
  162.           slowly (and take more memory).
  163.  
  164.           The first time the compiler must  build  a  call  to  a
  165.           member  function  (or  reference  to a data member), it
  166.           must (1) determine whether the class implements  member
  167.           functions  of that name; (2) resolve which member func-
  168.           tion to call (which involves figuring out what sorts of
  169.           type  conversions  need  to be made); and (3) check the
  170.           visibility of the member function to the  caller.   All
  171.           of  this  adds up to slower compilation.  Normally, the
  172.           second time a call is made to that member function  (or
  173.           reference  to that data member), it must go through the
  174.           same lengthy process again.  This means that code  like
  175.           this
  176.  
  177.             cout << "This " << p << " has " << n << " legs.\n";
  178.  
  179.           makes six passes through all three steps.  By  using  a
  180.           software  cache,  a  ``hit'' significantly reduces this
  181.           cost.   Unfortunately,  using  the   cache   introduces
  182.           another  layer of mechanisms which must be implemented,
  183.           and so incurs its  own  overhead.   `-fmemoize-lookups'
  184.           enables the software cache.
  185.  
  186.           Because access privileges (visibility) to  members  and
  187.           member  functions  may differ from one function context
  188.           to the next, g++ may need to flush the cache. With  the
  189.           `-fmemoize-lookups'  flag,  the  cache is flushed after
  190.           every function that is compiled.  The `-fsave-memoized'
  191.           flag  enables  the  same  software  cache, but when the
  192.  
  193.  
  194.  
  195. GNU Tools            Last change: 30apr1993                     3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. G++(1)                      GNU Tools                      G++(1)
  203.  
  204.  
  205.  
  206.           compiler determines that the context of the last  func-
  207.           tion compiled would yield the same access privileges of
  208.           the next function to compile, it preserves  the  cache.
  209.           This  is  most  helpful when defining many member func-
  210.           tions for the same class: with the exception of  member
  211.           functions  which  are  friends  of  other classes, each
  212.           member function has exactly th