home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / gnu / gcc-2.5.8-bin.lha / man / cat1 / g++.0 < prev    next >
Encoding:
Text File  |  1994-02-08  |  22.2 KB  |  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 the same access  privileges
  213.           as every other, and the cache need not be flushed.
  214.  
  215.      -fno-default-inline
  216.           Do not make member functions inline by  default  merely
  217.           because  they are defined inside the class scope.  Oth-
  218.           erwise, when you specify -O, member  functions  defined
  219.           inside  class  scope  are  compiled  inline by default;
  220.           i.e., you don't need to add `inline' in  front  of  the
  221.           member function name.
  222.  
  223.      -fno-strict-prototype
  224.           Consider the declaration int foo  ();.   In  C++,  this
  225.           means  that  the  function  foo takes no arguments.  In
  226.           ANSI C, this is declared int foo(void);.  With the flag
  227.           `-fno-strict-prototype',  declaring  functions  with no
  228.           arguments is equivalent to declaring its argument  list
  229.           to  be untyped, i.e., int foo (); is equivalent to say-
  230.           ing int foo (...);.
  231.  
  232.      -fnonnull-objects
  233.           Normally, GNU C++ makes conservative assumptions  about
  234.           objects  reached  through references.  For example, the
  235.           compiler must check that `a' is not null in  code  like
  236.           the following:
  237.               obj &a = g ();
  238.               a.f (2);
  239.           Checking that references of  this  sort  have  non-null
  240.           values requires extra code, however, and it is unneces-
  241.           sary    for    many    programs.     You    can     use
  242.           `-fnonnull-objects'  to  omit  the  checks for null, if
  243.           your program doesn't require the default checking.
  244.  
  245.      -fthis-is-variable
  246.           The incorporation of user-defined free store management
  247.           into  C++  has  made assignment to this an anachronism.
  248.           Therefore, by default GNU C++ treats the type  of  this
  249.           in  a  member  function  of class X to be X *const.  In
  250.           other words, it is illegal to assign to this  within  a
  251.           class member function.  However, for backwards compati-
  252.           bility, you  can  invoke  the  old  behavior  by  using
  253.           `-fthis-is-variable'.
  254.  
  255.      -g   Produce debugging information in the operating system's
  256.           native  format (for DBX or SDB or DWARF).  GDB also can
  257.           work with this debugging information.  On most  systems
  258.  
  259.  
  260.  
  261. GNU Tools            Last change: 30apr1993                     4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. G++(1)                      GNU Tools                      G++(1)
  269.  
  270.  
  271.  
  272.           that  use  DBX format, `-g' enables use of extra debug-
  273.           ging information that only GDB can use.
  274.  
  275.           Unlike most other C compilers, GNU CC allows you to use
  276.           `-g'  with `-O'.  The shortcuts taken by optimized code
  277.           may occasionally produce surprising results: some vari-
  278.           ables  you  declared may not exist at all; flow of con-
  279.           trol may briefly move where you did not expect it; some
  280.           statements  may  not  be  executed because they compute
  281.           constant results or their values were already at  hand;
  282.           some statements may execute in different places because
  283.           they were moved out of loops.
  284.  
  285.           Nevertheless it proves possible to debug optimized out-
  286.           put.  This makes it reasonable to use the optimizer for
  287.           programs that might have bugs.
  288.  
  289.      -I_d_i_r
  290.            Append  directory  _d_i_r  to  the  list  of  directories
  291.           searched for include files.
  292.  
  293.      -L_d_i_r
  294.            Add directory _d_i_r to the list  of  directories  to  be
  295.           searched for `-l'.
  296.  
  297.      -l_l_i_b_r_a_r_y
  298.            Use the library named _l_i_b_r_a_r_y when linking.  (C++ pro-
  299.           grams often require `-lg++' for successful linking.)
  300.  
  301.      -nostdinc
  302.           Do not  search  the  standard  system  directories  for
  303.           header  files.  Only the directories you have specified
  304.           with  -I  options  (and  the  current   directory,   if
  305.           appropriate) are searched.
  306.  
  307.      -nostdinc++
  308.           Do not search for header files in the  standard  direc-
  309.           tories  specific  to C++, but do still search the other
  310.           standard directories.  (This option is used when build-
  311.           ing libg++.)
  312.  
  313.      -O   Optimize.  Optimizing compilation takes  somewhat  more
  314.           time, and a lot more memory for a large function.
  315.  
  316.      -o _f_i_l_e
  317.            Place output in file _f_i_l_e.
  318.  
  319.      -S   Stop after the stage  of  compilation  proper;  do  not
  320.           assemble.   The  output  is  an assembler code file for
  321.           each non-assembler input file specified.
  322.  
  323.      -traditional
  324.  
  325.  
  326.  
  327. GNU Tools            Last change: 30apr1993                     5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. G++(1)                      GNU Tools                      G++(1)
  335.  
  336.  
  337.  
  338.           Attempt to support some aspects of traditional  C  com-
  339.           pilers.
  340.  
  341.           Specifically, for both C and C++ programs:
  342.  
  343.         o+ In the preprocessor, comments  convert  to  nothing  at
  344.           all,  rather  than to a space.  This allows traditional
  345.           token concatenation.
  346.  
  347.         o+ In the preprocessor,  macro  arguments  are  recognized
  348.           within  string  constants  in  a  macro definition (and
  349.           their values are stringified, though without additional
  350.           quote  marks, when they appear in such a context).  The
  351.           preprocessor always considers a string constant to  end
  352.           at a newline.
  353.  
  354.         o+ The preprocessor does not predefine the macro  __STDC__
  355.           when     you     use    `-traditional',    but    still
  356.           predefines__GNUC__ (since the GNU extensions  indicated
  357.           by  __GNUC__  are  not affected by `-traditional').  If
  358.           you need to write header files  that  work  differently
  359.           depending on whether `-traditional' is in use, by test-
  360.           ing both of these predefined macros you can distinguish
  361.           four situations: GNU C, traditional GNU C, other ANSI C
  362.           compilers, and other old C compilers.
  363.  
  364.         o+ In the preprocessor, comments  convert  to  nothing  at
  365.           all,  rather  than to a space.  This allows traditional
  366.           token concatenation.
  367.  
  368.         o+ In the preprocessor,  macro  arguments  are  recognized
  369.           within  string  constants  in  a  macro definition (and
  370.           their values are stringified, though without additional
  371.           quote  marks, when they appear in such a context).  The
  372.           preprocessor always considers a string constant to  end
  373.           at a newline.
  374.  
  375.         o+ The preprocessor does not predefine the macro  __STDC__
  376.           when     you     use    `-traditional',    but    still
  377.           predefines__GNUC__ (since the GNU extensions  indicated
  378.           by  __GNUC__  are  not affected by `-traditional').  If
  379.           you need to write header files  that  work  differently
  380.           depending on whether `-traditional' is in use, by test-
  381.           ing both of these predefined macros you can distinguish
  382.           four situations: GNU C, traditional GNU C, other ANSI C
  383.           compilers, and other old C compilers.
  384.  
  385.         o+ String ``constants'' are not necessarily constant; they
  386.           are  stored  in  writable  space, and identical looking
  387.           constants are allocated separately.
  388.  
  389.           For C++ programs only (not C), `-traditional'  has  one
  390.  
  391.  
  392.  
  393. GNU Tools            Last change: 30apr1993                     6
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. G++(1)                      GNU Tools                      G++(1)
  401.  
  402.  
  403.  
  404.           additional  effect:  assignment  to  this is permitted.
  405.           This is the same as the effect of `-fthis-is-variable'.
  406.  
  407.      -U_m_a_c_r_o
  408.           Undefine macro _m_a_c_r_o.
  409.  
  410.      -Wall
  411.           Issue warnings for conditions which  pertain  to  usage
  412.           that  we recommend avoiding and that we believe is easy
  413.           to avoid, even in conjunction with macros.
  414.  
  415.      -Wenum-clash
  416.           Warn  when  converting  between  different  enumeration
  417.           types.
  418.  
  419.      -Woverloaded-virtual
  420.           In a derived class, the definitions  of  virtual  func-
  421.           tions  must match the type signature of a virtual func-
  422.           tion declared in the base class.  Use  this  option  to
  423.           request  warnings when a derived class declares a func-
  424.           tion that may be an erroneous attempt to define a  vir-
  425.           tual  function:  that is, warn when a function with the
  426.           same name as a virtual function in the base class,  but
  427.           with  a  type  signature that doesn't match any virtual
  428.           functions from the base class.
  429.  
  430.      -Wtemplate-debugging
  431.           When using templates in a C++ program, warn  if  debug-
  432.           ging is not yet fully available.
  433.  
  434.      -w   Inhibit all warning messages.
  435.  
  436.      +e_N  Control how virtual function definitions are used, in a
  437.           fashion compatible with cfront 1.x.
  438.  
  439. PRAGMAS
  440.      Two `#pragma' directives are supported for GNU C++, to  per-
  441.      mit using the same header file for two purposes: as a defin-
  442.      ition of interfaces to a given object class, and as the full
  443.      definition of the contents of that object class.
  444.  
  445.      #pragma interface
  446.           Use this directive in header files that  define  object
  447.           classes, to save space in most of the object files that
  448.           use those classes.  Normally, local copies  of  certain
  449.           information  (backup copies of inline member functions,
  450.           debugging information, and  the  internal  tables  that
  451.           implement  virtual  functions)  must  be  kept  in each
  452.           object file that includes class definitions.   You  can
  453.           use  this  pragma  to  avoid  such duplication.  When a
  454.           header file containing `#pragma interface' is  included
  455.           in  a  compilation, this auxiliary information will not
  456.  
  457.  
  458.  
  459. GNU Tools            Last change: 30apr1993                     7
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. G++(1)                      GNU Tools                      G++(1)
  467.  
  468.  
  469.  
  470.           be generated (unless the main input source file  itself
  471.           uses  `#pragma  implementation').   Instead, the object
  472.           files will contain references to be  resolved  at  link
  473.           time.
  474.  
  475.      #pragma implementation
  476.  
  477.      #pragma implementation "_o_b_j_e_c_t_s.h"
  478.           Use this pragma in a main input  file,  when  you  want
  479.           full  output from included header files to be generated
  480.           (and made globally visible).  The included header file,
  481.           in  turn, should use `#pragma interface'. Backup copies
  482.           of inline member functions, debugging information,  and
  483.           the internal tables used to implement virtual functions
  484.           are all generated in implementation files.
  485.  
  486.           If you use `#pragma implementation' with  no  argument,
  487.           it applies to an include file with the same basename as
  488.           your  source  file;  for  example,  in   `allclass.cc',
  489.           `#pragma  implementation'  by  itself  is equivalent to
  490.           `#pragma implementation "allclass.h"'.  Use the  string
  491.           argument  if  you  want a single implementation file to
  492.           include code from multiple header files.
  493.  
  494.           There is no way to split up the contents  of  a  single
  495.           header file into multiple implementation files.
  496.  
  497. FILES
  498.      file.h             C header (preprocessor) file
  499.      file.i             preprocessed C source file
  500.      file.C             C++ source file
  501.      file.cc            C++ source file
  502.      file.cxx           C++ source file
  503.      file.s             assembly language file
  504.      file.o             object file
  505.      a.out              link edited output
  506.      _T_M_P_D_I_R/cc*         temporary files
  507.      _L_I_B_D_I_R/cpp         preprocessor
  508.      _L_I_B_D_I_R/cc1plus     compiler
  509.      _L_I_B_D_I_R/collect     linker front end needed on some machines
  510.      _L_I_B_D_I_R/libgcc.a    GCC subroutine library
  511.      /lib/crt[01n].o    start-up routine
  512.      _L_I_B_D_I_R/ccrt0       additional start-up routine for C++
  513.      /lib/libc.a        standard C library, see _i_n_t_r_o(3)
  514.      /usr/include       standard directory for #include files
  515.      _L_I_B_D_I_R/include     standard gcc directory for #include files
  516.      _L_I_B_D_I_R/g++-include additional g++ directory for #include
  517.  
  518.      _L_I_B_D_I_R is usually /usr/local/lib/_m_a_c_h_i_n_e/_v_e_r_s_i_o_n.
  519.      _T_M_P_D_I_R comes from the environment variable  TMPDIR  (default
  520.      /usr/tmp if available, else /tmp).
  521.  
  522.  
  523.  
  524.  
  525. GNU Tools            Last change: 30apr1993                     8
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. G++(1)                      GNU Tools                      G++(1)
  533.  
  534.  
  535.  
  536. SEE ALSO
  537.      gcc(1),  cpp(1),  as(1),  ld(1),  gdb(1),  adb(1),   dbx(1),
  538.      sdb(1).
  539.      `gcc', `cpp', `as',`ld', and `gdb' entries in info.
  540.      _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.
  541.      Stallman; _T_h_e _C _P_r_e_p_r_o_c_e_s_s_o_r, Richard M. Stallman; _D_e_b_u_g_g_i_n_g
  542.      _w_i_t_h _G_D_B: _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
  543.      and  Roland H. Pesch; _U_s_i_n_g _a_s: _t_h_e _G_N_U _A_s_s_e_m_b_l_e_r, Dean Els-
  544.      ner, Jay Fenlason & friends;  _g_l_d:  _t_h_e  _G_N_U  _l_i_n_k_e_r,  Steve
  545.      Chamberlain and Roland Pesch.
  546.  
  547.  
  548. BUGS
  549.      For instructions on how to report bugs, see the GCC manual.
  550.  
  551.  
  552. COPYING
  553.      Copyright (c) 1991, 1992,  1993  Free  Software  Foundation,
  554.      Inc.
  555.  
  556.      Permission is granted to make and distribute verbatim copies
  557.      of  this  manual provided the copyright notice and this per-
  558.      mission notice are preserved on all copies.
  559.  
  560.      Permission is granted to copy and distribute  modified  ver-
  561.      sions of this manual under the conditions for verbatim copy-
  562.      ing, provided that the entire resulting derived work is dis-
  563.      tributed under the terms of a permission notice identical to
  564.      this one.
  565.  
  566.      Permission is granted to copy and distribute translations of
  567.      this  manual  into  another language, under the above condi-
  568.      tions for modified versions,  except  that  this  permission
  569.      notice  may be included in translations approved by the Free
  570.      Software Foundation instead of in the original English.
  571.  
  572. AUTHORS
  573.      See the GNU CC Manual for the contributors to GNU CC.
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591. GNU Tools            Last change: 30apr1993                     9
  592.  
  593.  
  594.  
  595.