home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / djgpp / docs / gcc / gcc.i2 < prev    next >
Encoding:
GNU Info File  |  1993-05-29  |  46.8 KB  |  1,167 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
  29.  
  30. Options Controlling C Dialect
  31. =============================
  32.  
  33.    The following options control the dialect of C (or languages derived
  34. from C, such as C++ and Objective C) that the compiler accepts:
  35.  
  36. `-ansi'
  37.      Support all ANSI standard C programs.
  38.  
  39.      This turns off certain features of GNU C that are incompatible
  40.      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
  41.      predefined macros such as `unix' and `vax' that identify the type
  42.      of system you are using.  It also enables the undesirable and
  43.      rarely used ANSI trigraph feature, and disallows `$' as part of
  44.      identifiers.
  45.  
  46.      The alternate keywords `__asm__', `__extension__', `__inline__'
  47.      and `__typeof__' continue to work despite `-ansi'.  You would not
  48.      want to use them in an ANSI C program, of course, but it useful to
  49.      put them in header files that might be included in compilations
  50.      done with `-ansi'.  Alternate predefined macros such as `__unix__'
  51.      and `__vax__' are also available, with or without `-ansi'.
  52.  
  53.      The `-ansi' option does not cause non-ANSI programs to be rejected
  54.      gratuitously.  For that, `-pedantic' is required in addition to
  55.      `-ansi'.  *Note Warning Options::.
  56.  
  57.      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
  58.      is used.  Some header files may notice this macro and refrain from
  59.      declaring certain functions or defining certain macros that the
  60.      ANSI standard doesn't call for; this is to avoid interfering with
  61.      any programs that might use these names for other things.
  62.  
  63.      The functions `alloca', `abort', `exit', and `_exit' are not
  64.      builtin functions when `-ansi' is used.
  65.  
  66. `-fno-asm'
  67.      Do not recognize `asm', `inline' or `typeof' as a keyword.  These
  68.      words may then be used as identifiers.  You can use the keywords
  69.      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
  70.      `-fno-asm'.
  71.  
  72. `-fno-builtin'
  73.      Don't recognize built-in functions that do not begin with two
  74.      leading underscores.  Currently, the functions affected include
  75.      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
  76.      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
  77.      `strlen'.
  78.  
  79.      The `-ansi' option prevents `alloca' and `ffs' from being builtin
  80.      functions, since these functions do not have an ANSI standard
  81.      meaning.
  82.  
  83. `-trigraphs'
  84.      Support ANSI C trigraphs.  You don't want to know about this
  85.      brain-damage.  The `-ansi' option implies `-trigraphs'.
  86.  
  87. `-traditional'
  88.      Attempt to support some aspects of traditional C compilers.
  89.      Specifically:
  90.  
  91.         * All `extern' declarations take effect globally even if they
  92.           are written inside of a function definition.  This includes
  93.           implicit declarations of functions.
  94.  
  95.         * The keywords `typeof', `inline', `signed', `const' and
  96.           `volatile' are not recognized.  (You can still use the
  97.           alternative keywords such as `__typeof__', `__inline__', and
  98.           so on.)
  99.  
  100.         * Comparisons between pointers and integers are always allowed.
  101.  
  102.         * Integer types `unsigned short' and `unsigned char' promote to
  103.           `unsigned int'.
  104.  
  105.         * Out-of-range floating point literals are not an error.
  106.  
  107.         * Certain constructs which ANSI regards as a single invalid
  108.           preprocessing number, such as `0xe-0xd', are treated as
  109.           expressions instead.
  110.  
  111.         * String "constants" are not necessarily constant; they are
  112.           stored in writable space, and identical looking constants are
  113.           allocated separately.  (This is the same as the effect of
  114.           `-fwritable-strings'.)
  115.  
  116.         * All automatic variables not declared `register' are preserved
  117.           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
  118.           variables not declared `volatile' may be clobbered.
  119.  
  120.         * In the preprocessor, comments convert to nothing at all,
  121.           rather than to a space.  This allows traditional token
  122.           concatenation.
  123.  
  124.         * In the preprocessor, macro arguments are recognized within
  125.           string constants in a macro definition (and their values are
  126.           stringified, though without additional quote marks, when they
  127.           appear in such a context).  The preprocessor always considers
  128.           a string constant to end at a newline.
  129.  
  130.         * The predefined macro `__STDC__' is not defined when you use
  131.           `-traditional', but `__GNUC__' is (since the GNU extensions
  132.           which `__GNUC__' indicates are not affected by
  133.           `-traditional').  If you need to write header files that work
  134.           differently depending on whether `-traditional' is in use, by
  135.           testing both of these predefined macros you can distinguish
  136.           four situations: GNU C, traditional GNU C, other ANSI C
  137.           compilers, and other old C compilers.  *Note Standard
  138.           Predefined Macros: (cpp.info)Standard Predefined, for more
  139.           discussion of these and other predefined macros.
  140.  
  141.         * The preprocessor considers a string constant to end at a
  142.           newline (unless the newline is escaped with `\').  (Without
  143.           `-traditional', string constants can contain the newline
  144.           character as typed.)
  145.  
  146.         * The character escape sequences `\x' and `\a' evaluate as the
  147.           literal characters `x' and `a' respectively.  Without
  148.           `-traditional', `\x' is a prefix for the hexadecimal
  149.           representation of a character, and `\a' produces a bell.
  150.  
  151.         * In C++ programs, assignment to `this' is permitted with
  152.           `-traditional'.  This is the same as the effect of
  153.           `-fthis-is-variable'.
  154.  
  155.      You may wish to use `-fno-builtin' as well as `-traditional' if
  156.      your program uses names that are normally GNU C builtin functions
  157.      for other purposes of its own.
  158.  
  159. `-traditional-cpp'
  160.      Attempt to support some aspects of traditional C preprocessors.
  161.      This includes the last three items in the table immediately above,
  162.      but none of the other effects of `-traditional'.
  163.  
  164. `-fcond-mismatch'
  165.      Allow conditional expressions with mismatched types in the second
  166.      and third arguments.  The value of such an expression is void.
  167.  
  168. `-funsigned-char'
  169.      Let the type `char' be unsigned, like `unsigned char'.
  170.  
  171.      Each kind of machine has a default for what `char' should be.  It
  172.      is either like `unsigned char' by default or like `signed char' by
  173.      default.
  174.  
  175.      Ideally, a portable program should always use `signed char' or
  176.      `unsigned char' when it depends on the signedness of an object.
  177.      But many programs have been written to use plain `char' and expect
  178.      it to be signed, or expect it to be unsigned, depending on the
  179.      machines they were written for.  This option, and its inverse, let
  180.      you make such a program work with the opposite default.
  181.  
  182.      The type `char' is always a distinct type from each of `signed
  183.      char' or `unsigned char', even though its behavior is always just
  184.      like one of those two.
  185.  
  186. `-fsigned-char'
  187.      Let the type `char' be signed, like `signed char'.
  188.  
  189.      Note that this is equivalent to `-fno-unsigned-char', which is the
  190.      negative form of `-funsigned-char'.  Likewise, the option
  191.      `-fno-signed-char' is equivalent to `-funsigned-char'.
  192.  
  193. `-fsigned-bitfields'
  194. `-funsigned-bitfields'
  195. `-fno-signed-bitfields'
  196. `-fno-unsigned-bitfields'
  197.      These options control whether a bitfield is signed or unsigned,
  198.      when the declaration does not use either `signed' or `unsigned'.
  199.      By default, such a bitfield is signed, because this is consistent:
  200.      the basic integer types such as `int' are signed types.
  201.  
  202.      However, when `-traditional' is used, bitfields are all unsigned
  203.      no matter what.
  204.  
  205. `-fwritable-strings'
  206.      Store string constants in the writable data segment and don't
  207.      uniquize them.  This is for compatibility with old programs which
  208.      assume they can write into string constants.  The option
  209.      `-traditional' also has this effect.
  210.  
  211.      Writing into string constants is a very bad idea; "constants"
  212.      should be constant.
  213.  
  214. 
  215. File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
  216.  
  217. Options Controlling C++ Dialect
  218. ===============================
  219.  
  220.    This section describes the command-line options that are only
  221. meaningful for C++ programs; but you can also use most of the GNU
  222. compiler options regardless of what language your program is in.  For
  223. example, you might compile a file `firstClass.C' like this:
  224.  
  225.      g++ -g -felide-constructors -O -c firstClass.C
  226.  
  227. In this example, only `-felide-constructors' is an option meant only
  228. for C++ programs; you can use the other options with any language
  229. supported by GNU CC.
  230.  
  231.    Here is a list of options that are *only* for compiling C++ programs:
  232.  
  233. `-fall-virtual'
  234.      Treat all possible member functions as virtual, implicitly.  All
  235.      member functions (except for constructor functions and `new' or
  236.      `delete' member operators) are treated as virtual functions of the
  237.      class where they appear.
  238.  
  239.      This does not mean that all calls to these member functions will
  240.      be made through the internal table of virtual functions.  Under
  241.      some circumstances, the compiler can determine that a call to a
  242.      given virtual function can be made directly; in these cases the
  243.      calls are direct in any case.
  244.  
  245. `-fdollars-in-identifiers'
  246.      Accept `$' in identifiers.  You can also explicitly prohibit use of
  247.      `$' with `-fno-dollars-in-identifiers'.  (GNU C++ allows `$' by
  248.      default on some target systems but not others.)  Traditional C
  249.      allowed the character `$' to form part of identifiers.  However,
  250.      ANSI C and C++ forbid `$' in identifiers.
  251.  
  252. `-felide-constructors'
  253.      Elide constructors when this seems plausible.  With this option,
  254.      GNU C++ initializes `y' directly from the call to `foo' without
  255.      going through a temporary in the following code:
  256.  
  257.           A foo ();
  258.           A y = foo ();
  259.  
  260.      Without this option, GNU C++ (1) initializes `y' by calling the
  261.      appropriate constructor for type `A'; (2) assigns the result of
  262.      `foo' to a temporary; and, finally, (3) replaces the initial value
  263.      of `y' with the temporary.
  264.  
  265.      The default behavior (`-fno-elide-constructors') is specified by
  266.      the draft ANSI C++ standard.  If your program's constructors have
  267.      side effects, `-felide-constructors' can change your program's
  268.      behavior, since some constructor calls may be omitted.
  269.  
  270. `-fenum-int-equiv'
  271.      Permit implicit conversion of `int' to enumeration types.  Normally
  272.      GNU C++ allows conversion of `enum' to `int', but not the other
  273.      way around.
  274.  
  275. `-fmemoize-lookups'
  276. `-fsave-memoized'
  277.      Use heuristics to compile faster.  These heuristics are not
  278.      enabled by default, since they are only effective for certain
  279.      input files.  Other input files compile more slowly.
  280.  
  281.      The first time the compiler must build a call to a member function
  282.      (or reference to a data member), it must (1) determine whether the
  283.      class implements member functions of that name; (2) resolve which
  284.      member function to call (which involves figuring out what sorts of
  285.      type conversions need to be made); and (3) check the visibility of
  286.      the member function to the caller.  All of this adds up to slower
  287.      compilation.  Normally, the second time a call is made to that
  288.      member function (or reference to that data member), it must go
  289.      through the same lengthy process again.  This means that code like
  290.      this:
  291.  
  292.           cout << "This " << p << " has " << n << " legs.\n";
  293.  
  294.      makes six passes through all three steps.  By using a software
  295.      cache, a "hit" significantly reduces this cost.  Unfortunately,
  296.      using the cache introduces another layer of mechanisms which must
  297.      be implemented, and so incurs its own overhead.
  298.      `-fmemoize-lookups' enables the software cache.
  299.  
  300.      Because access privileges (visibility) to members and member
  301.      functions may differ from one function context to the next, G++
  302.      may need to flush the cache.  With the `-fmemoize-lookups' flag,
  303.      the cache is flushed after every function that is compiled.  The
  304.      `-fsave-memoized' flag enables the same software cache, but when
  305.      the compiler determines that the context of the last function
  306.      compiled would yield the same access privileges of the next
  307.      function to compile, it preserves the cache.  This is most helpful
  308.      when defining many member functions for the same class: with the
  309.      exception of member functions which are friends of other classes,
  310.      each member function has exactly the same access privileges as
  311.      every other, and the cache need not be flushed.
  312.  
  313. `-fno-strict-prototype'
  314.      Treat a function declaration with no arguments, such as
  315.      `int foo ();', as C would treat it--as saying nothing about the
  316.      number of arguments or their types.  Normally, such a declaration
  317.      in C++ means that the function `foo' takes no arguments.
  318.  
  319. `-fnonnull-objects'
  320.      Assume that objects reached through references are not null.
  321.  
  322.      Normally, GNU C++ makes conservative assumptions about objects
  323.      reached through references.  For example, the compiler must check
  324.      that `a' is not null in code like the following:
  325.  
  326.           obj &a = g ();
  327.           a.f (2);
  328.  
  329.      Checking that references of this sort have non-null values requires
  330.      extra code, however, and it is unnecessary for many programs.  You
  331.      can use `-fnonnull-objects' to omit the checks for null, if your
  332.      program doesn't require checking.
  333.  
  334. `-fthis-is-variable'
  335.      Permit assignment to `this'.  The incorporation of user-defined
  336.      free store management into C++ has made assignment to `this' an
  337.      anachronism.  Therefore, by default it is invalid to assign to
  338.      `this' within a class member function; that is, GNU C++ treats the
  339.      type of `this' in a member function of class `X' to be `X *const'.
  340.      However, for backwards compatibility, you can make it valid with
  341.      `-fthis-is-variable'.
  342.  
  343. `-nostdinc++'
  344.      Do not search for header files in the standard directories
  345.      specific to C++, but do still search the other standard
  346.      directories.  (This option is used when building libg++.)
  347.  
  348. `-traditional'
  349.      For C++ programs (in addition to the effects that apply to both C
  350.      and C++), this has the same effect as `-fthis-is-variable'.  *Note
  351.      Options Controlling C Dialect: C Dialect Options.
  352.  
  353.    In addition, these optimization, warning, and code generation options
  354. have meanings only for C++ programs:
  355.  
  356. `-fno-default-inline'
  357.      Do not assume `inline' for functions defined inside a class scope.
  358.      *Note Options That Control Optimization: Optimize Options.
  359.  
  360. `-Wenum-clash'
  361. `-Woverloaded-virtual'
  362. `-Wtemplate-debugging'
  363.      Warnings that apply only to C++ programs.  *Note Options to
  364.      Request or Suppress Warnings: Warning Options.
  365.  
  366. `+eN'
  367.      Control how virtual function definitions are used, in a fashion
  368.      compatible with `cfront' 1.x.  *Note Options for Code Generation
  369.      Conventions: Code Gen Options.
  370.  
  371. 
  372. File: gcc.info,  Node: Warning Options,  Next: Debugging Options,  Prev: C++ Dialect Options,  Up: Invoking GCC
  373.  
  374. Options to Request or Suppress Warnings
  375. =======================================
  376.  
  377.    Warnings are diagnostic messages that report constructions which are
  378. not inherently erroneous but which are risky or suggest there may have
  379. been an error.
  380.  
  381.    You can request many specific warnings with options beginning `-W',
  382. for example `-Wimplicit' to request warnings on implicit declarations.
  383. Each of these specific warning options also has a negative form
  384. beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'.
  385. This manual lists only one of the two forms, whichever is not the
  386. default.
  387.  
  388.    These options control the amount and kinds of warnings produced by
  389. GNU CC:
  390.  
  391. `-fsyntax-only'
  392.      Check the code for syntax errors, but don't do anything beyond
  393.      that.
  394.  
  395. `-w'
  396.      Inhibit all warning messages.
  397.  
  398. `-Wno-import'
  399.      Inhibit warning messages about the use of `#import'.
  400.  
  401. `-pedantic'
  402.      Issue all the warnings demanded by strict ANSI standard C; reject
  403.      all programs that use forbidden extensions.
  404.  
  405.      Valid ANSI standard C programs should compile properly with or
  406.      without this option (though a rare few will require `-ansi').
  407.      However, without this option, certain GNU extensions and
  408.      traditional C features are supported as well.  With this option,
  409.      they are rejected.
  410.  
  411.      `-pedantic' does not cause warning messages for use of the
  412.      alternate keywords whose names begin and end with `__'.  Pedantic
  413.      warnings are also disabled in the expression that follows
  414.      `__extension__'.  However, only system header files should use
  415.      these escape routes; application programs should avoid them.
  416.      *Note Alternate Keywords::.
  417.  
  418.      This option is not intended to be useful; it exists only to satisfy
  419.      pedants who would otherwise claim that GNU CC fails to support the
  420.      ANSI standard.
  421.  
  422.      Some users try to use `-pedantic' to check programs for strict ANSI
  423.      C conformance.  They soon find that it does not do quite what they
  424.      want: it finds some non-ANSI practices, but not all--only those
  425.      for which ANSI C *requires* a diagnostic.
  426.  
  427.      A feature to report any failure to conform to ANSI C might be
  428.      useful in some instances, but would require considerable
  429.      additional work and would be quite different from `-pedantic'.  We
  430.      recommend, rather, that users take advantage of the extensions of
  431.      GNU C and disregard the limitations of other compilers.  Aside
  432.      from certain supercomputers and obsolete small machines, there is
  433.      less and less reason ever to use any other C compiler other than
  434.      for bootstrapping GNU CC.
  435.  
  436. `-pedantic-errors'
  437.      Like `-pedantic', except that errors are produced rather than
  438.      warnings.
  439.  
  440. `-W'
  441.      Print extra warning messages for these events:
  442.  
  443.         * A nonvolatile automatic variable might be changed by a call to
  444.           `longjmp'.  These warnings as well are possible only in
  445.           optimizing compilation.
  446.  
  447.           The compiler sees only the calls to `setjmp'.  It cannot know
  448.           where `longjmp' will be called; in fact, a signal handler
  449.           could call it at any point in the code.  As a result, you may
  450.           get a warning even when there is in fact no problem because
  451.           `longjmp' cannot in fact be called at the place which would
  452.           cause a problem.
  453.  
  454.         * A function can return either with or without a value.
  455.           (Falling off the end of the function body is considered
  456.           returning without a value.)  For example, this function would
  457.           evoke such a warning:
  458.  
  459.                foo (a)
  460.                {
  461.                  if (a > 0)
  462.                    return a;
  463.                }
  464.  
  465.         * An expression-statement contains no side effects.
  466.  
  467.         * An unsigned value is compared against zero with `>' or `<='.
  468.  
  469.         * A comparison like `x<=y<=z' appears; this is equivalent to
  470.           `(x<=y ? 1 : 0) <= z', which is a different interpretation
  471.           from that of ordinary mathematical notation.
  472.  
  473.         * Storage-class specifiers like `static' are not the first
  474.           things in a declaration.  According to the C Standard, this
  475.           usage is obsolescent.
  476.  
  477.         * An aggregate has a partly bracketed initializer.  For
  478.           example, the following code would evoke such a warning,
  479.           because braces are missing around the initializer for `x.h':
  480.  
  481.                struct s { int f, g; };
  482.                struct t { struct s h; int i; };
  483.                struct t x = { 1, 2, 3 };
  484.  
  485. `-Wimplicit'
  486.      Warn whenever a function or parameter is implicitly declared.
  487.  
  488. `-Wreturn-type'
  489.      Warn whenever a function is defined with a return-type that
  490.      defaults to `int'.  Also warn about any `return' statement with no
  491.      return-value in a function whose return-type is not `void'.
  492.  
  493. `-Wunused'
  494.      Warn whenever a local variable is unused aside from its
  495.      declaration, whenever a function is declared static but never
  496.      defined, and whenever a statement computes a result that is
  497.      explicitly not used.
  498.  
  499.      If you want to prevent a warning for a particular variable, you
  500.      can use this macro:
  501.  
  502.           #define USE(var) \
  503.             static void * use_##var = (&use_##var, (void *) &var)
  504.           
  505.           USE (string);
  506.  
  507. `-Wswitch'
  508.      Warn whenever a `switch' statement has an index of enumeral type
  509.      and lacks a `case' for one or more of the named codes of that
  510.      enumeration.  (The presence of a `default' label prevents this
  511.      warning.)  `case' labels outside the enumeration range also
  512.      provoke warnings when this option is used.
  513.  
  514. `-Wcomment'
  515.      Warn whenever a comment-start sequence `/*' appears in a comment.
  516.  
  517. `-Wtrigraphs'
  518.      Warn if any trigraphs are encountered (assuming they are enabled).
  519.  
  520. `-Wformat'
  521.      Check calls to `printf' and `scanf', etc., to make sure that the
  522.      arguments supplied have types appropriate to the format string
  523.      specified.
  524.  
  525. `-Wchar-subscripts'
  526.      Warn if an array subscript has type `char'.  This is a common cause
  527.      of error, as programmers often forget that this type is signed on
  528.      some machines.
  529.  
  530. `-Wuninitialized'
  531.      An automatic variable is used without first being initialized.
  532.  
  533.      These warnings are possible only in optimizing compilation,
  534.      because they require data flow information that is computed only
  535.      when optimizing.  If you don't specify `-O', you simply won't get
  536.      these warnings.
  537.  
  538.      These warnings occur only for variables that are candidates for
  539.      register allocation.  Therefore, they do not occur for a variable
  540.      that is declared `volatile', or whose address is taken, or whose
  541.      size is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
  542.      structures, unions or arrays, even when they are in registers.
  543.  
  544.      Note that there may be no warning about a variable that is used
  545.      only to compute a value that itself is never used, because such
  546.      computations may be deleted by data flow analysis before the
  547.      warnings are printed.
  548.  
  549.      These warnings are made optional because GNU CC is not smart
  550.      enough to see all the reasons why the code might be correct
  551.      despite appearing to have an error.  Here is one example of how
  552.      this can happen:
  553.  
  554.           {
  555.             int x;
  556.             switch (y)
  557.               {
  558.               case 1: x = 1;
  559.                 break;
  560.               case 2: x = 4;
  561.                 break;
  562.               case 3: x = 5;
  563.               }
  564.             foo (x);
  565.           }
  566.  
  567.      If the value of `y' is always 1, 2 or 3, then `x' is always
  568.      initialized, but GNU CC doesn't know this.  Here is another common
  569.      case:
  570.  
  571.           {
  572.             int save_y;
  573.             if (change_y) save_y = y, y = new_y;
  574.             ...
  575.             if (change_y) y = save_y;
  576.           }
  577.  
  578.      This has no bug because `save_y' is used only if it is set.
  579.  
  580.      Some spurious warnings can be avoided if you declare all the
  581.      functions you use that never return as `volatile'.  *Note Function
  582.      Attributes::.
  583.  
  584. `-Wparentheses'
  585.      Warn if parentheses are omitted in certain contexts, such as when
  586.      there is an assignment in a context where a truth value is
  587.      expected, or when operators are nested whose precedence people
  588.      often get confused about.
  589.  
  590. `-Wenum-clash'
  591.      Warn about conversion between different enumeration types.  (C++
  592.      only).
  593.  
  594. `-Wtemplate-debugging'
  595.      When using templates in a C++ program, warn if debugging is not yet
  596.      fully available (C++ only).
  597.  
  598. `-Wall'
  599.      All of the above `-W' options combined.  These are all the options
  600.      which pertain to usage that we recommend avoiding and that we
  601.      believe is easy to avoid, even in conjunction with macros.
  602.  
  603.    The remaining `-W...' options are not implied by `-Wall' because
  604. they warn about constructions that we consider reasonable to use, on
  605. occasion, in clean programs.
  606.  
  607. `-Wtraditional'
  608.      Warn about certain constructs that behave differently in
  609.      traditional and ANSI C.
  610.  
  611.         * Macro arguments occurring within string constants in the
  612.           macro body.  These would substitute the argument in
  613.           traditional C, but are part of the constant in ANSI C.
  614.  
  615.         * A function declared external in one block and then used after
  616.           the end of the block.
  617.  
  618.         * A `switch' statement has an operand of type `long'.
  619.  
  620. `-Wshadow'
  621.      Warn whenever a local variable shadows another local variable.
  622.  
  623. `-Wid-clash-LEN'
  624.      Warn whenever two distinct identifiers match in the first LEN
  625.      characters.  This may help you prepare a program that will compile
  626.      with certain obsolete, brain-damaged compilers.
  627.  
  628. `-Wpointer-arith'
  629.      Warn about anything that depends on the "size of" a function type
  630.      or of `void'.  GNU C assigns these types a size of 1, for
  631.      convenience in calculations with `void *' pointers and pointers to
  632.      functions.
  633.  
  634. `-Wcast-qual'
  635.      Warn whenever a pointer is cast so as to remove a type qualifier
  636.      from the target type.  For example, warn if a `const char *' is
  637.      cast to an ordinary `char *'.
  638.  
  639. `-Wcast-align'
  640.      Warn whenever a pointer is cast such that the required alignment
  641.      of the target is increased.  For example, warn if a `char *' is
  642.      cast to an `int *' on machines where integers can only be accessed
  643.      at two- or four-byte boundaries.
  644.  
  645. `-Wwrite-strings'
  646.      Give string constants the type `const char[LENGTH]' so that
  647.      copying the address of one into a non-`const' `char *' pointer
  648.      will get a warning.  These warnings will help you find at compile
  649.      time code that can try to write into a string constant, but only
  650.      if you have been very careful about using `const' in declarations
  651.      and prototypes.  Otherwise, it will just be a nuisance; this is
  652.      why we did not make `-Wall' request these warnings.
  653.  
  654. `-Wconversion'
  655.      Warn if a prototype causes a type conversion that is different
  656.      from what would happen to the same argument in the absence of a
  657.      prototype.  This includes conversions of fixed point to floating
  658.      and vice versa, and conversions changing the width or signedness
  659.      of a fixed point argument except when the same as the default
  660.      promotion.
  661.  
  662.      Also, warn if a negative integer constant expression is implicitly
  663.      converted to an unsigned type.  For example, warn about the
  664.      assignment `x = -1' if `x' is unsigned.  But do not warn about
  665.      explicit casts like `(unsigned) -1'.
  666.  
  667. `-Waggregate-return'
  668.      Warn if any functions that return structures or unions are defined
  669.      or called.  (In languages where you can return an array, this also
  670.      elicits a warning.)
  671.  
  672. `-Wstrict-prototypes'
  673.      Warn if a function is declared or defined without specifying the
  674.      argument types.  (An old-style function definition is permitted
  675.      without a warning if preceded by a declaration which specifies the
  676.      argument types.)
  677.  
  678. `-Wmissing-prototypes'
  679.      Warn if a global function is defined without a previous prototype
  680.      declaration.  This warning is issued even if the definition itself
  681.      provides a prototype.  The aim is to detect global functions that
  682.      fail to be declared in header files.
  683.  
  684. `-Wredundant-decls'
  685.      Warn if anything is declared more than once in the same scope,
  686.      even in cases where multiple declaration is valid and changes
  687.      nothing.
  688.  
  689. `-Wnested-externs'
  690.      Warn if an `extern' declaration is encountered within an function.
  691.  
  692. `-Winline'
  693.      Warn if a function can not be inlined, and either it was declared
  694.      as inline, or else the `-finline-functions' option was given.
  695.  
  696. `-Woverloaded-virtual'
  697.      Warn when a derived class function declaration may be an error in
  698.      defining a virtual function (C++ only).  In a derived class, the
  699.      definitions of virtual functions must match the type signature of a
  700.      virtual function declared in the base class.  With this option, the
  701.      compiler warns when you define a function with the same name as a
  702.      virtual function, but with a type signature that does not match any
  703.      declarations from the base class.
  704.  
  705. `-Werror'
  706.      Make all warnings into errors.
  707.  
  708. 
  709. File: gcc.info,  Node: Debugging Options,  Next: Optimize Options,  Prev: Warning Options,  Up: Invoking GCC
  710.  
  711. Options for Debugging Your Program or GNU CC
  712. ============================================
  713.  
  714.    GNU CC has various special options that are used for debugging
  715. either your program or GCC:
  716.  
  717. `-g'
  718.      Produce debugging information in the operating system's native
  719.      format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
  720.      debugging information.
  721.  
  722.      On most systems that use stabs format, `-g' enables use of extra
  723.      debugging information that only GDB can use; this extra information
  724.      makes debugging work better in GDB but will probably make other
  725.      debuggers crash or refuse to read the program.  If you want to
  726.      control for certain whether to generate the extra information, use
  727.      `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or
  728.      `-gdwarf' (see below).
  729.  
  730.      Unlike most other C compilers, GNU CC allows you to use `-g' with
  731.      `-O'.  The shortcuts taken by optimized code may occasionally
  732.      produce surprising results: some variables you declared may not
  733.      exist at all; flow of control may briefly move where you did not
  734.      expect it; some statements may not be executed because they
  735.      compute constant results or their values were already at hand;
  736.      some statements may execute in different places because they were
  737.      moved out of loops.
  738.  
  739.      Nevertheless it proves possible to debug optimized output.  This
  740.      makes it reasonable to use the optimizer for programs that might
  741.      have bugs.
  742.  
  743.      The following options are useful when GNU CC is generated with the
  744.      capability for more than one debugging format.
  745.  
  746. `-ggdb'
  747.      Produce debugging information in the native format (if that is
  748.      supported), including GDB extensions if at all possible.
  749.  
  750. `-gstabs'
  751.      Produce debugging information in stabs format (if that is
  752.      supported), without GDB extensions.  This is the format used by
  753.      DBX on most BSD systems.
  754.  
  755. `-gstabs+'
  756.      Produce debugging information in stabs format (if that is
  757.      supported), using GNU extensions understood only by the GNU
  758.      debugger (GDB).  The use of these extensions is likely to make
  759.      other debuggers crash or refuse to read the program.
  760.  
  761. `-gcoff'
  762.      Produce debugging information in COFF format (if that is
  763.      supported).  This is the format used by SDB on most System V
  764.      systems prior to System V Release 4.
  765.  
  766. `-gxcoff'
  767.      Produce debugging information in XCOFF format (if that is
  768.      supported).  This is the format used by the DBX debugger on IBM
  769.      RS/6000 systems.
  770.  
  771. `-gxcoff+'
  772.      Produce debugging information in XCOFF format (if that is
  773.      supported), using GNU extensions understood only by the GNU
  774.      debugger (GDB).  The use of these extensions is likely to make
  775.      other debuggers crash or refuse to read the program.
  776.  
  777. `-gdwarf'
  778.      Produce debugging information in DWARF format (if that is
  779.      supported).  This is the format used by SDB on most System V
  780.      Release 4 systems.
  781.  
  782. `-gdwarf+'
  783.      Produce debugging information in DWARF format (if that is
  784.      supported), using GNU extensions understood only by the GNU
  785.      debugger (GDB).  The use of these extensions is likely to make
  786.      other debuggers crash or refuse to read the program.
  787.  
  788. `-gLEVEL'
  789. `-ggdbLEVEL'
  790. `-gstabsLEVEL'
  791. `-gcoffLEVEL'
  792. `-gxcoffLEVEL'
  793. `-gdwarfLEVEL'
  794.      Request debugging information and also use LEVEL to specify how
  795.      much information.  The default level is 2.
  796.  
  797.      Level 1 produces minimal information, enough for making backtraces
  798.      in parts of the program that you don't plan to debug.  This
  799.      includes descriptions of functions and external variables, but no
  800.      information about local variables and no line numbers.
  801.  
  802.      Level 3 includes extra information, such as all the macro
  803.      definitions present in the program.  Some debuggers support macro
  804.      expansion when you use `-g3'.
  805.  
  806. `-p'
  807.      Generate extra code to write profile information suitable for the
  808.      analysis program `prof'.  You must use this option when compiling
  809.      the source files you want data about, and you must also use it when
  810.      linking.
  811.  
  812. `-pg'
  813.      Generate extra code to write profile information suitable for the
  814.      analysis program `gprof'.  You must use this option when compiling
  815.      the source files you want data about, and you must also use it when
  816.      linking.
  817.  
  818. `-a'
  819.      Generate extra code to write profile information for basic blocks,
  820.      which will record the number of times each basic block is executed.
  821.      This data could be analyzed by a program like `tcov'.  Note,
  822.      however, that the format of the data is not what `tcov' expects.
  823.      Eventually GNU `gprof' should be extended to process this data.
  824.  
  825. `-dLETTERS'
  826.      Says to make debugging dumps during compilation at times specified
  827.      by LETTERS.  This is used for debugging the compiler.  The file
  828.      names for most of the dumps are made by appending a word to the
  829.      source file name (e.g.  `foo.c.rtl' or `foo.c.jump').  Here are the
  830.      possible letters for use in LETTERS, and their meanings:
  831.  
  832.     `M'
  833.           Dump all macro definitions, at the end of preprocessing, and
  834.           write no output.
  835.  
  836.     `N'
  837.           Dump all macro names, at the end of preprocessing.
  838.  
  839.     `D'
  840.           Dump all macro definitions, at the end of preprocessing, in
  841.           addition to normal output.
  842.  
  843.     `y'
  844.           Dump debugging information during parsing, to standard error.
  845.  
  846.     `r'
  847.           Dump after RTL generation, to `FILE.rtl'.
  848.  
  849.     `x'
  850.           Just generate RTL for a function instead of compiling it.
  851.           Usually used with `r'.
  852.  
  853.     `j'
  854.           Dump after first jump optimization, to `FILE.jump'.
  855.  
  856.     `s'
  857.           Dump after CSE (including the jump optimization that sometimes
  858.           follows CSE), to `FILE.cse'.
  859.  
  860.     `L'
  861.           Dump after loop optimization, to `FILE.loop'.
  862.  
  863.     `t'
  864.           Dump after the second CSE pass (including the jump
  865.           optimization that sometimes follows CSE), to `FILE.cse2'.
  866.  
  867.     `f'
  868.           Dump after flow analysis, to `FILE.flow'.
  869.  
  870.     `c'
  871.           Dump after instruction combination, to
  872.           `FILE.combine'.
  873.  
  874.     `S'
  875.           Dump after the first instruction scheduling pass, to
  876.           `FILE.sched'.
  877.  
  878.     `l'
  879.           Dump after local register allocation, to
  880.           `FILE.lreg'.
  881.  
  882.     `g'
  883.           Dump after global register allocation, to
  884.           `FILE.greg'.
  885.  
  886.     `R'
  887.           Dump after the second instruction scheduling pass, to
  888.           `FILE.sched2'.
  889.  
  890.     `J'
  891.           Dump after last jump optimization, to `FILE.jump2'.
  892.  
  893.     `d'
  894.           Dump after delayed branch scheduling, to `FILE.dbr'.
  895.  
  896.     `k'
  897.           Dump after conversion from registers to stack, to
  898.           `FILE.stack'.
  899.  
  900.     `a'
  901.           Produce all the dumps listed above.
  902.  
  903.     `m'
  904.           Print statistics on memory usage, at the end of the run, to
  905.           standard error.
  906.  
  907.     `p'
  908.           Annotate the assembler output with a comment indicating which
  909.           pattern and alternative was used.
  910.  
  911. `-fpretend-float'
  912.      When running a cross-compiler, pretend that the target machine
  913.      uses the same floating point format as the host machine.  This
  914.      causes incorrect output of the actual floating constants, but the
  915.      actual instruction sequence will probably be the same as GNU CC
  916.      would make when running on the target machine.
  917.  
  918. `-save-temps'
  919.      Store the usual "temporary" intermediate files permanently; place
  920.      them in the current directory and name them based on the source
  921.      file.  Thus, compiling `foo.c' with `-c -save-temps' would produce
  922.      files `foo.i' and `foo.s', as well as `foo.o'.
  923.  
  924. `-print-libgcc-file-name'
  925.      Print the full absolute name of the library file `libgcc.a' that
  926.      would be used when linking--and don't do anything else.  With this
  927.      option, GNU CC does not compile or link anything; it just prints
  928.      the file name.
  929.  
  930.      This is useful when you use `-nostdlib' but you do want to link
  931.      with `libgcc.a'.  You can do
  932.  
  933.           gcc -nostdlib FILES... `gcc -print-libgcc-file-name`
  934.  
  935. 
  936. File: gcc.info,  Node: Optimize Options,  Next: Preprocessor Options,  Prev: Debugging Options,  Up: Invoking GCC
  937.  
  938. Options That Control Optimization
  939. =================================
  940.  
  941.    These options control various sorts of optimizations:
  942.  
  943. `-O'
  944. `-O1'
  945.      Optimize.  Optimizing compilation takes somewhat more time, and a
  946.      lot more memory for a large function.
  947.  
  948.      Without `-O', the compiler's goal is to reduce the cost of
  949.      compilation and to make debugging produce the expected results.
  950.      Statements are independent: if you stop the program with a
  951.      breakpoint between statements, you can then assign a new value to
  952.      any variable or change the program counter to any other statement
  953.      in the function and get exactly the results you would expect from
  954.      the source code.
  955.  
  956.      Without `-O', only variables declared `register' are allocated in
  957.      registers.  The resulting compiled code is a little worse than
  958.      produced by PCC without `-O'.
  959.  
  960.      With `-O', the compiler tries to reduce code size and execution
  961.      time.
  962.  
  963.      When `-O' is specified, the two options `-fthread-jumps' and
  964.      `-fdelayed-branch' are turned on.  On some machines other flags may
  965.      also be turned on.
  966.  
  967. `-O2'
  968.      Optimize even more.  Nearly all supported optimizations that do not
  969.      involve a space-speed tradeoff are performed.  As compared to `-O',
  970.      this option increases both compilation time and the performance of
  971.      the generated code.
  972.  
  973.      `-O2' turns on all `-fFLAG' options that enable more optimization,
  974.      except for `-funroll-loops', `-funroll-all-loops' and
  975.      `-fomit-frame-pointer'.
  976.  
  977. `-O0'
  978.      Do not optimize.
  979.  
  980.      If you use multiple `-O' options, with or without level numbers,
  981.      the last such option is the one that is effective.
  982.  
  983.    Options of the form `-fFLAG' specify machine-independent flags.
  984. Most flags have both positive and negative forms; the negative form of
  985. `-ffoo' would be `-fno-foo'.  In the table below, only one of the forms
  986. is listed--the one which is not the default.  You can figure out the
  987. other form by either removing `no-' or adding it.
  988.  
  989. `-ffloat-store'
  990.      Do not store floating point variables in registers, and inhibit
  991.      other options that might change whether a floating point value is
  992.      taken from a register or memory.
  993.  
  994.      This option prevents undesirable excess precision on machines such
  995.      as the 68000 where the floating registers (of the 68881) keep more
  996.      precision than a `double' is supposed to have.  For most programs,
  997.      the excess precision does only good, but a few programs rely on the
  998.      precise definition of IEEE floating point.  Use `-ffloat-store' for
  999.      such programs.
  1000.  
  1001. `-fno-default-inline'
  1002.      Do not make member functions inline by default merely because they
  1003.      are defined inside the class scope (C++ only).  Otherwise, when
  1004.      you specify `-O', member functions defined inside class scope are
  1005.      compiled inline by default; i.e., you don't need to add `inline'
  1006.      in front of the member function name.
  1007.  
  1008. `-fno-defer-pop'
  1009.      Always pop the arguments to each function call as soon as that
  1010.      function returns.  For machines which must pop arguments after a
  1011.      function call, the compiler normally lets arguments accumulate on
  1012.      the stack for several function calls and pops them all at once.
  1013.  
  1014. `-fforce-mem'
  1015.      Force memory operands to be copied into registers before doing
  1016.      arithmetic on them.  This may produce better code by making all
  1017.      memory references potential common subexpressions.  When they are
  1018.      not common subexpressions, instruction combination should
  1019.      eliminate the separate register-load.  I am interested in hearing
  1020.      about the difference this makes.
  1021.  
  1022. `-fforce-addr'
  1023.      Force memory address constants to be copied into registers before
  1024.      doing arithmetic on them.  This may produce better code just as
  1025.      `-fforce-mem' may.  I am interested in hearing about the
  1026.      difference this makes.
  1027.  
  1028. `-fomit-frame-pointer'
  1029.      Don't keep the frame pointer in a register for functions that
  1030.      don't need one.  This avoids the instructions to save, set up and
  1031.      restore frame pointers; it also makes an extra register available
  1032.      in many functions.  *It also makes debugging impossible on some
  1033.      machines.*
  1034.  
  1035.      On some machines, such as the Vax, this flag has no effect, because
  1036.      the standard calling sequence automatically handles the frame
  1037.      pointer and nothing is saved by pretending it doesn't exist.  The
  1038.      machine-description macro `FRAME_POINTER_REQUIRED' controls
  1039.      whether a target machine supports this flag.  *Note Registers::.
  1040.  
  1041. `-fno-inline'
  1042.      Don't pay attention to the `inline' keyword.  Normally this option
  1043.      is used to keep the compiler from expanding any functions inline.
  1044.      Note that if you are not optimizing, no functions can be expanded
  1045.      inline.
  1046.  
  1047. `-finline-functions'
  1048.      Integrate all simple functions into their callers.  The compiler
  1049.      heuristically decides which functions are simple enough to be worth
  1050.      integrating in this way.
  1051.  
  1052.      If all calls to a given function are integrated, and the function
  1053.      is declared `static', then the function is normally not output as
  1054.      assembler code in its own right.
  1055.  
  1056. `-fkeep-inline-functions'
  1057.      Even if all calls to a given function are integrated, and the
  1058.      function is declared `static', nevertheless output a separate
  1059.      run-time callable version of the function.
  1060.  
  1061. `-fno-function-cse'
  1062.      Do not put function addresses in registers; make each instruction
  1063.      that calls a constant function contain the function's address
  1064.      explicitly.
  1065.  
  1066.      This option results in less efficient code, but some strange hacks
  1067.      that alter the assembler output may be confused by the
  1068.      optimizations performed when this option is not used.
  1069.  
  1070. `-ffast-math'
  1071.      This option allows GCC to violate some ANSI or IEEE rules and/or
  1072.      specifications in the interest of optimizing code for speed.  For
  1073.      example, it allows the compiler to assume arguments to the `sqrt'
  1074.      function are non-negative numbers.
  1075.  
  1076.      This option should never be turned on by any `-O' option since it
  1077.      can result in incorrect output for programs which depend on an
  1078.      exact implementation of IEEE or ANSI rules/specifications for math
  1079.      functions.
  1080.  
  1081.    The following options control specific optimizations.  The `-O2'
  1082. option turns on all of these optimizations except `-funroll-loops' and
  1083. `-funroll-all-loops'.  On most machines, the `-O' option turns on the
  1084. `-fthread-jumps' and `-fdelayed-branch' options, but specific machines
  1085. may handle it differently.
  1086.  
  1087.    You can use the following flags in the rare cases when "fine-tuning"
  1088. of optimizations to be performed is desired.
  1089.  
  1090. `-fstrength-reduce'
  1091.      Perform the optimizations of loop strength reduction and
  1092.      elimination of iteration variables.
  1093.  
  1094. `-fthread-jumps'
  1095.      Perform optimizations where we check to see if a jump branches to a
  1096.      location where another comparison subsumed by the first is found.
  1097.      If so, the first branch is redirected to either the destination of
  1098.      the second branch or a point immediately following it, depending
  1099.      on whether the condition is known to be true or false.
  1100.  
  1101. `-fcse-follow-jumps'
  1102.      In common subexpression elimination, scan through jump instructions
  1103.      when the target of the jump is not reached by any other path.  For
  1104.      example, when CSE encounters an `if' statement with an `else'
  1105.      clause, CSE will follow the jump when the condition tested is
  1106.      false.
  1107.  
  1108. `-fcse-skip-blocks'
  1109.      This is similar to `-fcse-follow-jumps', but causes CSE to follow
  1110.      jumps which conditionally skip over blocks.  When CSE encounters a
  1111.      simple `if' statement with no else clause, `-fcse-skip-blocks'
  1112.      causes CSE to follow the jump around the body of the `if'.
  1113.  
  1114. `-frerun-cse-after-loop'
  1115.      Re-run common subexpression elimination after loop optimizations
  1116.      has been performed.
  1117.  
  1118. `-fexpensive-optimizations'
  1119.      Perform a number of minor optimizations that are relatively
  1120.      expensive.
  1121.  
  1122. `-fdelayed-branch'
  1123.      If supported for the target machine, attempt to reorder
  1124.      instructions to exploit instruction slots available after delayed
  1125.      branch instructions.
  1126.  
  1127. `-fschedule-insns'
  1128.      If supported for the target machine, attempt to reorder
  1129.      instructions to eliminate execution stalls due to required data
  1130.      being unavailable.  This helps machines that have slow floating
  1131.      point or memory load instructions by allowing other instructions
  1132.      to be issued until the result of the load or floating point
  1133.      instruction is required.
  1134.  
  1135. `-fschedule-insns2'
  1136.      Similar to `-fschedule-insns', but requests an additional pass of
  1137.      instruction scheduling after register allocation has been done.
  1138.      This is especially useful on machines with a relatively small
  1139.      number of registers and where memory load instructions take more
  1140.      than one cycle.
  1141.  
  1142. `-fcaller-saves'
  1143.      Enable values to be allocated in registers that will be clobbered
  1144.      by function calls, by emitting extra instructions to save and
  1145.      restore the registers around such calls.  Such allocation is done
  1146.      only when it seems to result in better code than would otherwise
  1147.      be produced.
  1148.  
  1149.      This option is enabled by default on certain machines, usually
  1150.      those which have no call-preserved registers to use instead.
  1151.  
  1152. `-funroll-loops'
  1153.      Perform the optimization of loop unrolling.  This is only done for
  1154.      loops whose number of iterations can be determined at compile time
  1155.      or run time.  `-funroll-loop' implies `-fstrength-reduce' and
  1156.      `-frerun-cse-after-loop'.
  1157.  
  1158. `-funroll-all-loops'
  1159.      Perform the optimization of loop unrolling.  This is done for all
  1160.      loops and usually makes programs run more slowly.
  1161.      `-funroll-all-loops' implies `-fstrength-reduce' and
  1162.      `-frerun-cse-after-loop'.
  1163.  
  1164. `-fno-peephole'
  1165.      Disable any machine-specific peephole optimizations.
  1166.  
  1167.