OSDN Git Service

This commit was generated by cvs2svn to compensate for changes in r16274,
[pf3gnuchains/gcc-fork.git] / gcc / gcc.info-1
1 This is Info file gcc.info, produced by Makeinfo version 1.68 from the
2 input file gcc.texi.
3
4    This file documents the use and the internals of the GNU compiler.
5
6    Published by the Free Software Foundation 59 Temple Place - Suite 330
7 Boston, MA 02111-1307 USA
8
9    Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997 Free
10 Software Foundation, Inc.
11
12    Permission is granted to make and distribute verbatim copies of this
13 manual provided the copyright notice and this permission notice are
14 preserved on all copies.
15
16    Permission is granted to copy and distribute modified versions of
17 this manual under the conditions for verbatim copying, provided also
18 that the sections entitled "GNU General Public License," "Funding for
19 Free Software," and "Protect Your Freedom--Fight `Look And Feel'" are
20 included exactly as in the original, and provided that the entire
21 resulting derived work is distributed under the terms of a permission
22 notice identical to this one.
23
24    Permission is granted to copy and distribute translations of this
25 manual into another language, under the above conditions for modified
26 versions, except that the sections entitled "GNU General Public
27 License," "Funding for Free Software," and "Protect Your Freedom--Fight
28 `Look And Feel'", and this permission notice, may be included in
29 translations approved by the Free Software Foundation instead of in the
30 original English.
31
32 \1f
33 File: gcc.info,  Node: Top,  Next: G++ and GCC,  Up: (DIR)
34
35 Introduction
36 ************
37
38    This manual documents how to run, install and port the GNU compiler,
39 as well as its new features and incompatibilities, and how to report
40 bugs.  It corresponds to GNU CC version 2.7.2.
41
42 * Menu:
43
44
45 * G++ and GCC::     You can compile C or C++ programs.
46 * Invoking GCC::    Command options supported by `gcc'.
47 * Installation::    How to configure, compile and install GNU CC.
48 * C Extensions::    GNU extensions to the C language family.
49 * C++ Extensions::  GNU extensions to the C++ language.
50 * Gcov::            gcov: a GNU CC test coverage program.
51 * Trouble::         If you have trouble installing GNU CC.
52 * Bugs::            How, why and where to report bugs.
53 * Service::         How to find suppliers of support for GNU CC.
54 * Contributing::    How to contribute to testing and developing GNU CC.
55 * VMS::             Using GNU CC on VMS.
56
57 * Portability::     Goals of GNU CC's portability features.
58 * Interface::       Function-call interface of GNU CC output.
59 * Passes::          Order of passes, what they do, and what each file is for.
60 * RTL::             The intermediate representation that most passes work on.
61 * Machine Desc::    How to write machine description instruction patterns.
62 * Target Macros::   How to write the machine description C macros.
63 * Config::          Writing the `xm-MACHINE.h' file.
64 * Fragments::       Writing the `t-TARGET' and `x-HOST' files.
65
66 * Funding::         How to help assure funding for free software.
67 * Look and Feel::   Protect your freedom--fight "look and feel".
68
69 * Copying::         GNU General Public License says
70                      how you can copy and share GNU CC.
71 * Contributors::    People who have contributed to GNU CC.
72
73 * Index::           Index of concepts and symbol names.
74
75 \1f
76 File: gcc.info,  Node: G++ and GCC,  Next: Invoking GCC,  Prev: Top,  Up: Top
77
78 Compile C, C++, or Objective C
79 ******************************
80
81    The C, C++, and Objective C versions of the compiler are integrated;
82 the GNU C compiler can compile programs written in C, C++, or Objective
83 C.
84
85    "GCC" is a common shorthand term for the GNU C compiler.  This is
86 both the most general name for the compiler, and the name used when the
87 emphasis is on compiling C programs.
88
89    When referring to C++ compilation, it is usual to call the compiler
90 "G++".  Since there is only one compiler, it is also accurate to call
91 it "GCC" no matter what the language context; however, the term "G++"
92 is more useful when the emphasis is on compiling C++ programs.
93
94    We use the name "GNU CC" to refer to the compilation system as a
95 whole, and more specifically to the language-independent part of the
96 compiler.  For example, we refer to the optimization options as
97 affecting the behavior of "GNU CC" or sometimes just "the compiler".
98
99    Front ends for other languages, such as Ada 9X, Fortran, Modula-3,
100 and Pascal, are under development.  These front-ends, like that for
101 C++, are built in subdirectories of GNU CC and link to it.  The result
102 is an integrated compiler that can compile programs written in C, C++,
103 Objective C, or any of the languages for which you have installed front
104 ends.
105
106    In this manual, we only discuss the options for the C, Objective-C,
107 and C++ compilers and those of the GNU CC core.  Consult the
108 documentation of the other front ends for the options to use when
109 compiling programs written in other languages.
110
111    G++ is a *compiler*, not merely a preprocessor.  G++ builds object
112 code directly from your C++ program source.  There is no intermediate C
113 version of the program.  (By contrast, for example, some other
114 implementations use a program that generates a C program from your C++
115 source.)  Avoiding an intermediate C representation of the program means
116 that you get better object code, and better debugging information.  The
117 GNU debugger, GDB, works with this information in the object code to
118 give you comprehensive C++ source-level editing capabilities (*note C
119 and C++: (gdb.info)C.).
120
121 \1f
122 File: gcc.info,  Node: Invoking GCC,  Next: Installation,  Prev: G++ and GCC,  Up: Top
123
124 GNU CC Command Options
125 **********************
126
127    When you invoke GNU CC, it normally does preprocessing, compilation,
128 assembly and linking.  The "overall options" allow you to stop this
129 process at an intermediate stage.  For example, the `-c' option says
130 not to run the linker.  Then the output consists of object files output
131 by the assembler.
132
133    Other options are passed on to one stage of processing.  Some options
134 control the preprocessor and others the compiler itself.  Yet other
135 options control the assembler and linker; most of these are not
136 documented here, since you rarely need to use any of them.
137
138    Most of the command line options that you can use with GNU CC are
139 useful for C programs; when an option is only useful with another
140 language (usually C++), the explanation says so explicitly.  If the
141 description for a particular option does not mention a source language,
142 you can use that option with all supported languages.
143
144    *Note Compiling C++ Programs: Invoking G++, for a summary of special
145 options for compiling C++ programs.
146
147    The `gcc' program accepts options and file names as operands.  Many
148 options have multiletter names; therefore multiple single-letter options
149 may *not* be grouped: `-dr' is very different from `-d -r'.
150
151    You can mix options and other arguments.  For the most part, the
152 order you use doesn't matter.  Order does matter when you use several
153 options of the same kind; for example, if you specify `-L' more than
154 once, the directories are searched in the order specified.
155
156    Many options have long names starting with `-f' or with `-W'--for
157 example, `-fforce-mem', `-fstrength-reduce', `-Wformat' and so on.
158 Most of these have both positive and negative forms; the negative form
159 of `-ffoo' would be `-fno-foo'.  This manual documents only one of
160 these two forms, whichever one is not the default.
161
162 * Menu:
163
164 * Option Summary::      Brief list of all options, without explanations.
165 * Overall Options::     Controlling the kind of output:
166                         an executable, object files, assembler files,
167                         or preprocessed source.
168 * Invoking G++::        Compiling C++ programs.
169 * C Dialect Options::   Controlling the variant of C language compiled.
170 * C++ Dialect Options:: Variations on C++.
171 * Warning Options::     How picky should the compiler be?
172 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
173 * Optimize Options::    How much optimization?
174 * Preprocessor Options:: Controlling header files and macro definitions.
175                          Also, getting dependency information for Make.
176 * Assembler Options::   Passing options to the assembler.
177 * Link Options::        Specifying libraries and so on.
178 * Directory Options::   Where to find header files and libraries.
179                         Where to find the compiler executable files.
180 * Target Options::      Running a cross-compiler, or an old version of GNU CC.
181 * Submodel Options::    Specifying minor hardware or convention variations,
182                         such as 68010 vs 68020.
183 * Code Gen Options::    Specifying conventions for function calls, data layout
184                         and register usage.
185 * Environment Variables:: Env vars that affect GNU CC.
186 * Running Protoize::    Automatically adding or removing function prototypes.
187
188 \1f
189 File: gcc.info,  Node: Option Summary,  Next: Overall Options,  Up: Invoking GCC
190
191 Option Summary
192 ==============
193
194    Here is a summary of all the options, grouped by type.  Explanations
195 are in the following sections.
196
197 *Overall Options*
198      *Note Options Controlling the Kind of Output: Overall Options.
199           -c  -S  -E  -o FILE  -pipe  -v  -x LANGUAGE
200
201 *C Language Options*
202      *Note Options Controlling C Dialect: C Dialect Options.
203           -ansi  -fallow-single-precision  -fcond-mismatch  -fno-asm
204           -fno-builtin  -ffreestanding  -fhosted  -fsigned-bitfields  -fsigned-char
205           -funsigned-bitfields  -funsigned-char  -fwritable-strings
206           -traditional  -traditional-cpp  -trigraphs
207
208 *C++ Language Options*
209      *Note Options Controlling C++ Dialect: C++ Dialect Options.
210           -fall-virtual  -fdollars-in-identifiers  -felide-constructors
211           -fenum-int-equiv  -fexternal-templates  -ffor-scope  -fno-for-scope
212           -fhandle-signatures  -fmemoize-lookups  -fname-mangling-version-N
213           -fno-default-inline  -fno-gnu-keywords -fnonnull-objects -fguiding-decls
214           -foperator-names  -fstrict-prototype  -fthis-is-variable
215           -ftemplate-depth-N  -nostdinc++  -traditional  +eN
216
217 *Warning Options*
218      *Note Options to Request or Suppress Warnings: Warning Options.
219           -fsyntax-only  -pedantic  -pedantic-errors
220           -w  -W  -Wall  -Waggregate-return  -Wbad-function-cast
221           -Wcast-align  -Wcast-qual  -Wchar-subscript  -Wcomment
222           -Wconversion  -Werror  -Wformat
223           -Wid-clash-LEN  -Wimplicit -Wimplicit-int
224           -Wimplicit-function-declarations -Wimport  -Winline
225           -Wlarger-than-LEN  -Wmain  -Wmissing-declarations
226           -Wmissing-prototypes  -Wnested-externs
227           -Wno-import  -Woverloaded-virtual  -Wparentheses
228           -Wpointer-arith  -Wredundant-decls  -Wreorder  -Wreturn-type  -Wshadow
229           -Wsign-compare  -Wstrict-prototypes  -Wswitch  -Wsynth
230           -Wtemplate-debugging  -Wtraditional  -Wtrigraphs
231           -Wundef  -Wuninitialized  -Wunused  -Wwrite-strings
232
233 *Debugging Options*
234      *Note Options for Debugging Your Program or GCC: Debugging Options.
235           -a  -ax  -dLETTERS  -fpretend-float
236           -fprofile-arcs  -ftest-coverage
237           -g  -gLEVEL  -gcoff  -gdwarf  -gdwarf-1  -gdwarf-1+  -gdwarf-2
238           -ggdb  -gstabs  -gstabs+  -gxcoff  -gxcoff+
239           -p  -pg  -print-file-name=LIBRARY  -print-libgcc-file-name
240           -print-prog-name=PROGRAM  -print-search-dirs  -save-temps
241
242 *Optimization Options*
243      *Note Options that Control Optimization: Optimize Options.
244           -fbranch-probabilities
245           -fcaller-saves  -fcse-follow-jumps  -fcse-skip-blocks
246           -fdelayed-branch   -fexpensive-optimizations
247           -ffast-math  -ffloat-store  -fforce-addr  -fforce-mem
248           -ffunction-sections  -finline-functions
249           -fkeep-inline-functions  -fno-default-inline
250           -fno-defer-pop  -fno-function-cse
251           -fno-inline  -fno-peephole  -fomit-frame-pointer
252           -frerun-cse-after-loop  -fschedule-insns
253           -fschedule-insns2  -fstrength-reduce  -fthread-jumps
254           -funroll-all-loops  -funroll-loops
255           -O  -O0  -O1  -O2  -O3
256
257 *Preprocessor Options*
258      *Note Options Controlling the Preprocessor: Preprocessor Options.
259           -AQUESTION(ANSWER)  -C  -dD  -dM  -dN
260           -DMACRO[=DEFN]  -E  -H
261           -idirafter DIR
262           -include FILE  -imacros FILE
263           -iprefix FILE  -iwithprefix DIR
264           -iwithprefixbefore DIR  -isystem DIR
265           -M  -MD  -MM  -MMD  -MG  -nostdinc  -P  -trigraphs
266           -undef  -UMACRO  -Wp,OPTION
267
268 *Assembler Option*
269      *Note Passing Options to the Assembler: Assembler Options.
270           -Wa,OPTION
271
272 *Linker Options*
273      *Note Options for Linking: Link Options.
274           OBJECT-FILE-NAME  -lLIBRARY
275           -nostartfiles  -nodefaultlibs  -nostdlib
276           -s  -static  -shared  -symbolic
277           -Wl,OPTION  -Xlinker OPTION
278           -u SYMBOL
279
280 *Directory Options*
281      *Note Options for Directory Search: Directory Options.
282           -BPREFIX  -IDIR  -I-  -LDIR  -specs=FILE
283
284 *Target Options*
285      *Note Target Options::.
286           -b MACHINE  -V VERSION
287
288 *Machine Dependent Options*
289      *Note Hardware Models and Configurations: Submodel Options.
290           *M680x0 Options*
291           -m68000  -m68020  -m68020-40  -m68020-60  -m68030  -m68040
292           -m68060  -m5200  -m68881  -mbitfield  -mc68000  -mc68020  -mfpa
293           -mnobitfield  -mrtd  -mshort  -msoft-float  -malign-int
294           
295           *VAX Options*
296           -mg  -mgnu  -munix
297           
298           *SPARC Options*
299           -mcpu=CPU TYPE
300           -mtune=CPU TYPE
301           -mcmodel=CODE MODEL
302           -malign-jumps=NUM  -malign-loops=NUM
303           -malign-functions=NUM
304           -m32  -m64
305           -mapp-regs  -mbroken-saverestore  -mcypress  -mepilogue
306           -mflat  -mfpu  -mhard-float  -mhard-quad-float
307           -mimpure-text  -mlive-g0  -mno-app-regs  -mno-epilogue
308           -mno-flat  -mno-fpu  -mno-impure-text
309           -mno-stack-bias  -mno-unaligned-doubles
310           -msoft-float  -msoft-quad-float  -msparclite  -mstack-bias
311           -msupersparc  -munaligned-doubles  -mv8
312           
313           *Convex Options*
314           -mc1  -mc2  -mc32  -mc34  -mc38
315           -margcount  -mnoargcount
316           -mlong32  -mlong64
317           -mvolatile-cache  -mvolatile-nocache
318           
319           *AMD29K Options*
320           -m29000  -m29050  -mbw  -mnbw  -mdw  -mndw
321           -mlarge  -mnormal  -msmall
322           -mkernel-registers  -mno-reuse-arg-regs
323           -mno-stack-check  -mno-storem-bug
324           -mreuse-arg-regs  -msoft-float  -mstack-check
325           -mstorem-bug  -muser-registers
326           
327           *ARM Options*
328           -mapcs-frame  -mapcs-26  -mapcs-32
329           -mlittle-endian  -mbig-endian  -mwords-little-endian
330           -mshort-load-bytes  -mno-short-load-bytes
331           -msoft-float  -mhard-float
332           -mbsd  -mxopen  -mno-symrename
333           
334           *M32R/D Options*
335           -mcode-model=MODEL TYPE  -msdata=SDATA TYPE
336           -G NUM
337           
338           *M88K Options*
339           -m88000  -m88100  -m88110  -mbig-pic
340           -mcheck-zero-division  -mhandle-large-shift
341           -midentify-revision  -mno-check-zero-division
342           -mno-ocs-debug-info  -mno-ocs-frame-position
343           -mno-optimize-arg-area  -mno-serialize-volatile
344           -mno-underscores  -mocs-debug-info
345           -mocs-frame-position  -moptimize-arg-area
346           -mserialize-volatile  -mshort-data-NUM  -msvr3
347           -msvr4  -mtrap-large-shift  -muse-div-instruction
348           -mversion-03.00  -mwarn-passed-structs
349           
350           *RS/6000 and PowerPC Options*
351           -mcpu=CPU TYPE
352           -mtune=CPU TYPE
353           -mpower  -mno-power  -mpower2  -mno-power2
354           -mpowerpc  -mno-powerpc
355           -mpowerpc-gpopt  -mno-powerpc-gpopt
356           -mpowerpc-gfxopt  -mno-powerpc-gfxopt
357           -mnew-mnemonics  -mno-new-mnemonics
358           -mfull-toc   -mminimal-toc  -mno-fop-in-toc  -mno-sum-in-toc
359           -mxl-call  -mno-xl-call  -mthreads  -mpe
360           -msoft-float  -mhard-float  -mmultiple  -mno-multiple
361           -mstring  -mno-string  -mupdate  -mno-update
362           -mfused-madd  -mno-fused-madd  -mbit-align  -mno-bit-align
363           -mstrict-align  -mno-strict-align  -mrelocatable
364           -mno-relocatable  -mrelocatable-lib  -mno-relocatable-lib
365           -mtoc  -mno-toc  -mtraceback  -mno-traceback
366           -mlittle  -mlittle-endian  -mbig  -mbig-endian
367           -mcall-aix  -mcall-sysv  -mprototype  -mno-prototype
368           -msim  -mmvme  -mads  -myellowknife  -memb
369           -msdata  -msdata=OPT  -G NUM
370           
371           *RT Options*
372           -mcall-lib-mul  -mfp-arg-in-fpregs  -mfp-arg-in-gregs
373           -mfull-fp-blocks  -mhc-struct-return  -min-line-mul
374           -mminimum-fp-blocks  -mnohc-struct-return
375           
376           *MIPS Options*
377           -mabicalls  -mcpu=CPU TYPE  -membedded-data
378           -membedded-pic  -mfp32  -mfp64  -mgas  -mgp32  -mgp64
379           -mgpopt  -mhalf-pic  -mhard-float  -mint64  -mips1
380           -mips2  -mips3  -mlong64  -mlong-calls  -mmemcpy
381           -mmips-as  -mmips-tfile  -mno-abicalls
382           -mno-embedded-data  -mno-embedded-pic
383           -mno-gpopt  -mno-long-calls
384           -mno-memcpy  -mno-mips-tfile  -mno-rnames  -mno-stats
385           -mrnames  -msoft-float
386           -m4650  -msingle-float  -mmad
387           -mstats  -EL  -EB  -G NUM  -nocpp
388           
389           *i386 Options*
390           -m486  -m386  -mieee-fp  -mno-fancy-math-387
391           -mno-fp-ret-in-387  -msoft-float  -msvr3-shlib
392           -mno-wide-multiply  -mrtd  -malign-double
393           -mreg-alloc=LIST  -mregparm=NUM
394           -malign-jumps=NUM  -malign-loops=NUM
395           -malign-functions=NUM
396           
397           *HPPA Options*
398           -mbig-switch  -mdisable-fpregs  -mdisable-indexing  -mfast-indirect-calls
399           -mgas  -mjump-in-delay  -mlong-load-store  -mno-big-switch  -mno-disable-fpregs
400           -mno-disable-indexing  -mno-fast-indirect-calls  -mno-gas
401           -mno-jump-in-delay
402           -mno-long-load-store
403           -mno-portable-runtime  -mno-soft-float  -mno-space  -mno-space-regs
404           -msoft-float
405           -mpa-risc-1-0  -mpa-risc-1-1  -mportable-runtime
406           -mschedule=LIST  -mspace  -mspace-regs
407           
408           *Intel 960 Options*
409           -mCPU TYPE  -masm-compat  -mclean-linkage
410           -mcode-align  -mcomplex-addr  -mleaf-procedures
411           -mic-compat  -mic2.0-compat  -mic3.0-compat
412           -mintel-asm  -mno-clean-linkage  -mno-code-align
413           -mno-complex-addr  -mno-leaf-procedures
414           -mno-old-align  -mno-strict-align  -mno-tail-call
415           -mnumerics  -mold-align  -msoft-float  -mstrict-align
416           -mtail-call
417           
418           *DEC Alpha Options*
419           -mfp-regs  -mno-fp-regs
420           -mno-soft-float  -msoft-float
421           -mieee  -mieee-with-inexact  -mieee-conformant
422           -mfp-trap-mode  -mfp-rounding-mode  -mtrap-precision
423           -mbuild-constants
424           
425           *Clipper Options*
426           -mc300  -mc400
427           
428           *H8/300 Options*
429           -mrelax  -mh -ms -mint32  -malign-300
430           
431           *SH Options*
432           -m1  -m2  -m3  -m3e  -mb  -ml  -mrelax
433           
434           *System V Options*
435           -Qy  -Qn  -YP,PATHS  -Ym,DIR
436           
437           *V850 Options*
438           -mlong-calls -mno-long-calls -mep -mno-ep
439           -mprolog-function -mno-prolog-function -mspace
440           -mtda=N -msda=N -mzda=N
441           -mv850 -mbig-switch
442
443 *Code Generation Options*
444      *Note Options for Code Generation Conventions: Code Gen Options.
445           -fcall-saved-REG  -fcall-used-REG
446           -ffixed-REG  -finhibit-size-directive
447           -fcheck-memory-usage  -fprefix-function-name
448           -fno-common  -fno-ident  -fno-gnu-linker
449           -fpcc-struct-return  -fpic  -fPIC
450           -freg-struct-return  -fshared-data  -fshort-enums
451           -fshort-double  -fvolatile  -fvolatile-global
452           -fverbose-asm  -fpack-struct  -fstack-check  +e0  +e1
453
454 * Menu:
455
456 * Overall Options::     Controlling the kind of output:
457                         an executable, object files, assembler files,
458                         or preprocessed source.
459 * C Dialect Options::   Controlling the variant of C language compiled.
460 * C++ Dialect Options:: Variations on C++.
461 * Warning Options::     How picky should the compiler be?
462 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
463 * Optimize Options::    How much optimization?
464 * Preprocessor Options:: Controlling header files and macro definitions.
465                          Also, getting dependency information for Make.
466 * Assembler Options::   Passing options to the assembler.
467 * Link Options::        Specifying libraries and so on.
468 * Directory Options::   Where to find header files and libraries.
469                         Where to find the compiler executable files.
470 * Target Options::      Running a cross-compiler, or an old version of GNU CC.
471
472 \1f
473 File: gcc.info,  Node: Overall Options,  Next: Invoking G++,  Prev: Option Summary,  Up: Invoking GCC
474
475 Options Controlling the Kind of Output
476 ======================================
477
478    Compilation can involve up to four stages: preprocessing, compilation
479 proper, assembly and linking, always in that order.  The first three
480 stages apply to an individual source file, and end by producing an
481 object file; linking combines all the object files (those newly
482 compiled, and those specified as input) into an executable file.
483
484    For any given input file, the file name suffix determines what kind
485 of compilation is done:
486
487 `FILE.c'
488      C source code which must be preprocessed.
489
490 `FILE.i'
491      C source code which should not be preprocessed.
492
493 `FILE.ii'
494      C++ source code which should not be preprocessed.
495
496 `FILE.m'
497      Objective-C source code.  Note that you must link with the library
498      `libobjc.a' to make an Objective-C program work.
499
500 `FILE.h'
501      C header file (not to be compiled or linked).
502
503 `FILE.cc'
504 `FILE.cxx'
505 `FILE.cpp'
506 `FILE.C'
507      C++ source code which must be preprocessed.  Note that in `.cxx',
508      the last two letters must both be literally `x'.  Likewise, `.C'
509      refers to a literal capital C.
510
511 `FILE.s'
512      Assembler code.
513
514 `FILE.S'
515      Assembler code which must be preprocessed.
516
517 `OTHER'
518      An object file to be fed straight into linking.  Any file name
519      with no recognized suffix is treated this way.
520
521    You can specify the input language explicitly with the `-x' option:
522
523 `-x LANGUAGE'
524      Specify explicitly the LANGUAGE for the following input files
525      (rather than letting the compiler choose a default based on the
526      file name suffix).  This option applies to all following input
527      files until the next `-x' option.  Possible values for LANGUAGE
528      are:
529           c  objective-c  c++
530           c-header  cpp-output  c++-cpp-output
531           assembler  assembler-with-cpp
532
533 `-x none'
534      Turn off any specification of a language, so that subsequent files
535      are handled according to their file name suffixes (as they are if
536      `-x' has not been used at all).
537
538    If you only want some of the stages of compilation, you can use `-x'
539 (or filename suffixes) to tell `gcc' where to start, and one of the
540 options `-c', `-S', or `-E' to say where `gcc' is to stop.  Note that
541 some combinations (for example, `-x cpp-output -E' instruct `gcc' to do
542 nothing at all.
543
544 `-c'
545      Compile or assemble the source files, but do not link.  The linking
546      stage simply is not done.  The ultimate output is in the form of an
547      object file for each source file.
548
549      By default, the object file name for a source file is made by
550      replacing the suffix `.c', `.i', `.s', etc., with `.o'.
551
552      Unrecognized input files, not requiring compilation or assembly,
553      are ignored.
554
555 `-S'
556      Stop after the stage of compilation proper; do not assemble.  The
557      output is in the form of an assembler code file for each
558      non-assembler input file specified.
559
560      By default, the assembler file name for a source file is made by
561      replacing the suffix `.c', `.i', etc., with `.s'.
562
563      Input files that don't require compilation are ignored.
564
565 `-E'
566      Stop after the preprocessing stage; do not run the compiler
567      proper.  The output is in the form of preprocessed source code,
568      which is sent to the standard output.
569
570      Input files which don't require preprocessing are ignored.
571
572 `-o FILE'
573      Place output in file FILE.  This applies regardless to whatever
574      sort of output is being produced, whether it be an executable file,
575      an object file, an assembler file or preprocessed C code.
576
577      Since only one output file can be specified, it does not make
578      sense to use `-o' when compiling more than one input file, unless
579      you are producing an executable file as output.
580
581      If `-o' is not specified, the default is to put an executable file
582      in `a.out', the object file for `SOURCE.SUFFIX' in `SOURCE.o', its
583      assembler file in `SOURCE.s', and all preprocessed C source on
584      standard output.
585
586 `-v'
587      Print (on standard error output) the commands executed to run the
588      stages of compilation.  Also print the version number of the
589      compiler driver program and of the preprocessor and the compiler
590      proper.
591
592 `-pipe'
593      Use pipes rather than temporary files for communication between the
594      various stages of compilation.  This fails to work on some systems
595      where the assembler is unable to read from a pipe; but the GNU
596      assembler has no trouble.
597
598 \1f
599 File: gcc.info,  Node: Invoking G++,  Next: C Dialect Options,  Prev: Overall Options,  Up: Invoking GCC
600
601 Compiling C++ Programs
602 ======================
603
604    C++ source files conventionally use one of the suffixes `.C', `.cc',
605 `cpp', or `.cxx'; preprocessed C++ files use the suffix `.ii'.  GNU CC
606 recognizes files with these names and compiles them as C++ programs
607 even if you call the compiler the same way as for compiling C programs
608 (usually with the name `gcc').
609
610    However, C++ programs often require class libraries as well as a
611 compiler that understands the C++ language--and under some
612 circumstances, you might want to compile programs from standard input,
613 or otherwise without a suffix that flags them as C++ programs.  `g++'
614 is a program that calls GNU CC with the default language set to C++,
615 and automatically specifies linking against the GNU class library
616 libg++.  (1) On many systems, the script `g++' is also installed with
617 the name `c++'.
618
619    When you compile C++ programs, you may specify many of the same
620 command-line options that you use for compiling programs in any
621 language; or command-line options meaningful for C and related
622 languages; or options that are meaningful only for C++ programs.  *Note
623 Options Controlling C Dialect: C Dialect Options, for explanations of
624 options for languages related to C.  *Note Options Controlling C++
625 Dialect: C++ Dialect Options, for explanations of options that are
626 meaningful only for C++ programs.
627
628    ---------- Footnotes ----------
629
630    (1) Prior to release 2 of the compiler, there was a separate `g++'
631 compiler.  That version was based on GNU CC, but not integrated with
632 it.  Versions of `g++' with a `1.XX' version number--for example, `g++'
633 version 1.37 or 1.42--are much less reliable than the versions
634 integrated with GCC 2.  Moreover, combining G++ `1.XX' with a version 2
635 GCC will simply not work.
636
637 \1f
638 File: gcc.info,  Node: C Dialect Options,  Next: C++ Dialect Options,  Prev: Invoking G++,  Up: Invoking GCC
639
640 Options Controlling C Dialect
641 =============================
642
643    The following options control the dialect of C (or languages derived
644 from C, such as C++ and Objective C) that the compiler accepts:
645
646 `-ansi'
647      Support all ANSI standard C programs.
648
649      This turns off certain features of GNU C that are incompatible
650      with ANSI C, such as the `asm', `inline' and `typeof' keywords, and
651      predefined macros such as `unix' and `vax' that identify the type
652      of system you are using.  It also enables the undesirable and
653      rarely used ANSI trigraph feature, and it disables recognition of
654      C++ style `//' comments.
655
656      The alternate keywords `__asm__', `__extension__', `__inline__'
657      and `__typeof__' continue to work despite `-ansi'.  You would not
658      want to use them in an ANSI C program, of course, but it is useful
659      to put them in header files that might be included in compilations
660      done with `-ansi'.  Alternate predefined macros such as `__unix__'
661      and `__vax__' are also available, with or without `-ansi'.
662
663      The `-ansi' option does not cause non-ANSI programs to be rejected
664      gratuitously.  For that, `-pedantic' is required in addition to
665      `-ansi'.  *Note Warning Options::.
666
667      The macro `__STRICT_ANSI__' is predefined when the `-ansi' option
668      is used.  Some header files may notice this macro and refrain from
669      declaring certain functions or defining certain macros that the
670      ANSI standard doesn't call for; this is to avoid interfering with
671      any programs that might use these names for other things.
672
673      The functions `alloca', `abort', `exit', and `_exit' are not
674      builtin functions when `-ansi' is used.
675
676 `-fno-asm'
677      Do not recognize `asm', `inline' or `typeof' as a keyword, so that
678      code can use these words as identifiers.  You can use the keywords
679      `__asm__', `__inline__' and `__typeof__' instead.  `-ansi' implies
680      `-fno-asm'.
681
682      In C++, this switch only affects the `typeof' keyword, since `asm'
683      and `inline' are standard keywords.  You may want to use the
684      `-fno-gnu-keywords' flag instead, as it also disables the other,
685      C++-specific, extension keywords such as `headof'.
686
687 `-fno-builtin'
688      Don't recognize builtin functions that do not begin with two
689      leading underscores.  Currently, the functions affected include
690      `abort', `abs', `alloca', `cos', `exit', `fabs', `ffs', `labs',
691      `memcmp', `memcpy', `sin', `sqrt', `strcmp', `strcpy', and
692      `strlen'.
693
694      GCC normally generates special code to handle certain builtin
695      functions more efficiently; for instance, calls to `alloca' may
696      become single instructions that adjust the stack directly, and
697      calls to `memcpy' may become inline copy loops.  The resulting
698      code is often both smaller and faster, but since the function
699      calls no longer appear as such, you cannot set a breakpoint on
700      those calls, nor can you change the behavior of the functions by
701      linking with a different library.
702
703      The `-ansi' option prevents `alloca' and `ffs' from being builtin
704      functions, since these functions do not have an ANSI standard
705      meaning.
706
707 `-fhosted'
708      Assert that compilation takes place in a hosted environment.  This
709      implies `-fbuiltin'.  A hosted environment is one in which the
710      entire standard library is available, and in which `main' has a
711      return type of `int'.  Examples are nearly everything except a
712      kernel.  This is equivalent to `-fno-freestanding'.
713
714 `-ffreestanding'
715      Assert that compilation takes place in a freestanding environment.
716      This implies `-fno-builtin'.  A freestanding environment is one
717      in which the standard library may not exist, and program startup
718      may not necessarily be at `main'.  The most obvious example is an
719      OS kernel.  This is equivalent to `-fno-hosted'.
720
721 `-trigraphs'
722      Support ANSI C trigraphs.  You don't want to know about this
723      brain-damage.  The `-ansi' option implies `-trigraphs'.
724
725 `-traditional'
726      Attempt to support some aspects of traditional C compilers.
727      Specifically:
728
729         * All `extern' declarations take effect globally even if they
730           are written inside of a function definition.  This includes
731           implicit declarations of functions.
732
733         * The newer keywords `typeof', `inline', `signed', `const' and
734           `volatile' are not recognized.  (You can still use the
735           alternative keywords such as `__typeof__', `__inline__', and
736           so on.)
737
738         * Comparisons between pointers and integers are always allowed.
739
740         * Integer types `unsigned short' and `unsigned char' promote to
741           `unsigned int'.
742
743         * Out-of-range floating point literals are not an error.
744
745         * Certain constructs which ANSI regards as a single invalid
746           preprocessing number, such as `0xe-0xd', are treated as
747           expressions instead.
748
749         * String "constants" are not necessarily constant; they are
750           stored in writable space, and identical looking constants are
751           allocated separately.  (This is the same as the effect of
752           `-fwritable-strings'.)
753
754         * All automatic variables not declared `register' are preserved
755           by `longjmp'.  Ordinarily, GNU C follows ANSI C: automatic
756           variables not declared `volatile' may be clobbered.
757
758         * The character escape sequences `\x' and `\a' evaluate as the
759           literal characters `x' and `a' respectively.  Without
760           `-traditional', `\x' is a prefix for the hexadecimal
761           representation of a character, and `\a' produces a bell.
762
763         * In C++ programs, assignment to `this' is permitted with
764           `-traditional'.  (The option `-fthis-is-variable' also has
765           this effect.)
766
767      You may wish to use `-fno-builtin' as well as `-traditional' if
768      your program uses names that are normally GNU C builtin functions
769      for other purposes of its own.
770
771      You cannot use `-traditional' if you include any header files that
772      rely on ANSI C features.  Some vendors are starting to ship
773      systems with ANSI C header files and you cannot use `-traditional'
774      on such systems to compile files that include any system headers.
775
776      The `-traditional' option also enables the `-traditional-cpp'
777      option, which is described next.
778
779 `-traditional-cpp'
780      Attempt to support some aspects of traditional C preprocessors.
781      Specifically:
782
783         * Comments convert to nothing at all, rather than to a space.
784           This allows traditional token concatenation.
785
786         * In a preprocessing directive, the `#' symbol must appear as
787           the first character of a line.
788
789         * Macro arguments are recognized within string constants in a
790           macro definition (and their values are stringified, though
791           without additional quote marks, when they appear in such a
792           context).  The preprocessor always considers a string
793           constant to end at a newline.
794
795         * The predefined macro `__STDC__' is not defined when you use
796           `-traditional', but `__GNUC__' is (since the GNU extensions
797           which `__GNUC__' indicates are not affected by
798           `-traditional').  If you need to write header files that work
799           differently depending on whether `-traditional' is in use, by
800           testing both of these predefined macros you can distinguish
801           four situations: GNU C, traditional GNU C, other ANSI C
802           compilers, and other old C compilers.  The predefined macro
803           `__STDC_VERSION__' is also not defined when you use
804           `-traditional'.  *Note Standard Predefined Macros:
805           (cpp.info)Standard Predefined, for more discussion of these
806           and other predefined macros.
807
808         * The preprocessor considers a string constant to end at a
809           newline (unless the newline is escaped with `\').  (Without
810           `-traditional', string constants can contain the newline
811           character as typed.)
812
813 `-fcond-mismatch'
814      Allow conditional expressions with mismatched types in the second
815      and third arguments.  The value of such an expression is void.
816
817 `-funsigned-char'
818      Let the type `char' be unsigned, like `unsigned char'.
819
820      Each kind of machine has a default for what `char' should be.  It
821      is either like `unsigned char' by default or like `signed char' by
822      default.
823
824      Ideally, a portable program should always use `signed char' or
825      `unsigned char' when it depends on the signedness of an object.
826      But many programs have been written to use plain `char' and expect
827      it to be signed, or expect it to be unsigned, depending on the
828      machines they were written for.  This option, and its inverse, let
829      you make such a program work with the opposite default.
830
831      The type `char' is always a distinct type from each of `signed
832      char' or `unsigned char', even though its behavior is always just
833      like one of those two.
834
835 `-fsigned-char'
836      Let the type `char' be signed, like `signed char'.
837
838      Note that this is equivalent to `-fno-unsigned-char', which is the
839      negative form of `-funsigned-char'.  Likewise, the option
840      `-fno-signed-char' is equivalent to `-funsigned-char'.
841
842      You may wish to use `-fno-builtin' as well as `-traditional' if
843      your program uses names that are normally GNU C builtin functions
844      for other purposes of its own.
845
846      You cannot use `-traditional' if you include any header files that
847      rely on ANSI C features.  Some vendors are starting to ship
848      systems with ANSI C header files and you cannot use `-traditional'
849      on such systems to compile files that include any system headers.
850
851 `-fsigned-bitfields'
852 `-funsigned-bitfields'
853 `-fno-signed-bitfields'
854 `-fno-unsigned-bitfields'
855      These options control whether a bitfield is signed or unsigned,
856      when the declaration does not use either `signed' or `unsigned'.
857      By default, such a bitfield is signed, because this is consistent:
858      the basic integer types such as `int' are signed types.
859
860      However, when `-traditional' is used, bitfields are all unsigned
861      no matter what.
862
863 `-fwritable-strings'
864      Store string constants in the writable data segment and don't
865      uniquize them.  This is for compatibility with old programs which
866      assume they can write into string constants.  The option
867      `-traditional' also has this effect.
868
869      Writing into string constants is a very bad idea; "constants"
870      should be constant.
871
872 `-fallow-single-precision'
873      Do not promote single precision math operations to double
874      precision, even when compiling with `-traditional'.
875
876      Traditional K&R C promotes all floating point operations to double
877      precision, regardless of the sizes of the operands.   On the
878      architecture for which you are compiling, single precision may be
879      faster than double precision.   If you must use `-traditional',
880      but want to use single precision operations when the operands are
881      single precision, use this option.   This option has no effect
882      when compiling with ANSI or GNU C conventions (the default).
883
884 \1f
885 File: gcc.info,  Node: C++ Dialect Options,  Next: Warning Options,  Prev: C Dialect Options,  Up: Invoking GCC
886
887 Options Controlling C++ Dialect
888 ===============================
889
890    This section describes the command-line options that are only
891 meaningful for C++ programs; but you can also use most of the GNU
892 compiler options regardless of what language your program is in.  For
893 example, you might compile a file `firstClass.C' like this:
894
895      g++ -g -felide-constructors -O -c firstClass.C
896
897 In this example, only `-felide-constructors' is an option meant only
898 for C++ programs; you can use the other options with any language
899 supported by GNU CC.
900
901    Here is a list of options that are *only* for compiling C++ programs:
902
903 `-fno-access-control'
904      Turn off all access checking.  This switch is mainly useful for
905      working around bugs in the access control code.
906
907 `-fall-virtual'
908      Treat all possible member functions as virtual, implicitly.  All
909      member functions (except for constructor functions and `new' or
910      `delete' member operators) are treated as virtual functions of the
911      class where they appear.
912
913      This does not mean that all calls to these member functions will
914      be made through the internal table of virtual functions.  Under
915      some circumstances, the compiler can determine that a call to a
916      given virtual function can be made directly; in these cases the
917      calls are direct in any case.
918
919 `-fcheck-new'
920      Check that the pointer returned by `operator new' is non-null
921      before attempting to modify the storage allocated.  The current
922      Working Paper requires that `operator new' never return a null
923      pointer, so this check is normally unnecessary.
924
925 `-fconserve-space'
926      Put uninitialized or runtime-initialized global variables into the
927      common segment, as C does.  This saves space in the executable at
928      the cost of not diagnosing duplicate definitions.  If you compile
929      with this flag and your program mysteriously crashes after
930      `main()' has completed, you may have an object that is being
931      destroyed twice because two definitions were merged.
932
933 `-fdollars-in-identifiers'
934      Accept `$' in identifiers.  You can also explicitly prohibit use of
935      `$' with the option `-fno-dollars-in-identifiers'.  (GNU C allows
936      `$' by default on most target systems, but there are a few
937      exceptions.)  Traditional C allowed the character `$' to form part
938      of identifiers.  However, ANSI C and C++ forbid `$' in identifiers.
939
940 `-fenum-int-equiv'
941      Anachronistically permit implicit conversion of `int' to
942      enumeration types.  Current C++ allows conversion of `enum' to
943      `int', but not the other way around.
944
945 `-fexternal-templates'
946      Cause template instantiations to obey `#pragma interface' and
947      `implementation'; template instances are emitted or not according
948      to the location of the template definition.  *Note Template
949      Instantiation::, for more information.
950
951      This option is deprecated.
952
953 `-falt-external-templates'
954      Similar to -fexternal-templates, but template instances are
955      emitted or not according to the place where they are first
956      instantiated.  *Note Template Instantiation::, for more
957      information.
958
959      This option is deprecated.
960
961 `-ffor-scope'
962 `-fno-for-scope'
963      If -ffor-scope is specified, the scope of variables declared in a
964      for-init-statement is limited to the `for' loop itself, as
965      specified by the draft C++ standard.  If -fno-for-scope is
966      specified, the scope of variables declared in a for-init-statement
967      extends to the end of the enclosing scope, as was the case in old
968      versions of gcc, and other (traditional) implementations of C++.
969
970      The default if neither flag is given to follow the standard, but
971      to allow and give a warning for old-style code that would
972      otherwise be invalid, or have different behavior.
973
974 `-fno-gnu-keywords'
975      Do not recognize `classof', `headof', `signature', `sigof' or
976      `typeof' as a keyword, so that code can use these words as
977      identifiers.  You can use the keywords `__classof__',
978      `__headof__', `__signature__', `__sigof__', and `__typeof__'
979      instead.  `-ansi' implies `-fno-gnu-keywords'.
980
981 `-fguiding-decls'
982      Treat a function declaration with the same type as a potential
983      function template instantiation as though it declares that
984      instantiation, not a normal function.  If a definition is given
985      for the function later in the translation unit (or another
986      translation unit if the target supports weak symbols), that
987      definition will be used; otherwise the template will be
988      instantiated.  This behavior reflects the C++ language prior to
989      September 1996, when guiding declarations were removed.
990
991      This option implies `-fname-mangling-version-0', and will not work
992      with other name mangling versions.
993
994 `-fno-implicit-templates'
995      Never emit code for templates which are instantiated implicitly
996      (i.e. by use); only emit code for explicit instantiations.  *Note
997      Template Instantiation::, for more information.
998
999 `-fhandle-signatures'
1000      Recognize the `signature' and `sigof' keywords for specifying
1001      abstract types.  The default (`-fno-handle-signatures') is not to
1002      recognize them.  *Note Type Abstraction using Signatures: C++
1003      Signatures.
1004
1005 `-fhuge-objects'
1006      Support virtual function calls for objects that exceed the size
1007      representable by a `short int'.  Users should not use this flag by
1008      default; if you need to use it, the compiler will tell you so.  If
1009      you compile any of your code with this flag, you must compile
1010      *all* of your code with this flag (including libg++, if you use
1011      it).
1012
1013      This flag is not useful when compiling with -fvtable-thunks.
1014
1015 `-fno-implement-inlines'
1016      To save space, do not emit out-of-line copies of inline functions
1017      controlled by `#pragma implementation'.  This will cause linker
1018      errors if these functions are not inlined everywhere they are
1019      called.
1020
1021 `-fmemoize-lookups'
1022 `-fsave-memoized'
1023      Use heuristics to compile faster.  These heuristics are not
1024      enabled by default, since they are only effective for certain
1025      input files.  Other input files compile more slowly.
1026
1027      The first time the compiler must build a call to a member function
1028      (or reference to a data member), it must (1) determine whether the
1029      class implements member functions of that name; (2) resolve which
1030      member function to call (which involves figuring out what sorts of
1031      type conversions need to be made); and (3) check the visibility of
1032      the member function to the caller.  All of this adds up to slower
1033      compilation.  Normally, the second time a call is made to that
1034      member function (or reference to that data member), it must go
1035      through the same lengthy process again.  This means that code like
1036      this:
1037
1038           cout << "This " << p << " has " << n << " legs.\n";
1039
1040      makes six passes through all three steps.  By using a software
1041      cache, a "hit" significantly reduces this cost.  Unfortunately,
1042      using the cache introduces another layer of mechanisms which must
1043      be implemented, and so incurs its own overhead.
1044      `-fmemoize-lookups' enables the software cache.
1045
1046      Because access privileges (visibility) to members and member
1047      functions may differ from one function context to the next, G++
1048      may need to flush the cache.  With the `-fmemoize-lookups' flag,
1049      the cache is flushed after every function that is compiled.  The
1050      `-fsave-memoized' flag enables the same software cache, but when
1051      the compiler determines that the context of the last function
1052      compiled would yield the same access privileges of the next
1053      function to compile, it preserves the cache.  This is most helpful
1054      when defining many member functions for the same class: with the
1055      exception of member functions which are friends of other classes,
1056      each member function has exactly the same access privileges as
1057      every other, and the cache need not be flushed.
1058
1059      The code that implements these flags has rotted; you should
1060      probably avoid using them.
1061
1062 `-fstrict-prototype'
1063      Within an `extern "C"' linkage specification, treat a function
1064      declaration with no arguments, such as `int foo ();', as declaring
1065      the function to take no arguments.  Normally, such a declaration
1066      means that the function `foo' can take any combination of
1067      arguments, as in C.  `-pedantic' implies `-fstrict-prototype'
1068      unless overridden with `-fno-strict-prototype'.
1069
1070      This flag no longer affects declarations with C++ linkage.
1071
1072 `-fname-mangling-version-N'
1073      Control the way in which names are mangled.  Version 0 is
1074      compatible with versions of g++ before 2.8.  Version 1 is the
1075      default.  Version 1 will allow correct mangling of function
1076      templates.  For example, version 0 mangling does not mangle
1077      foo<int, double> and foo<int, char> given this declaration:
1078
1079           template <class T, class U> void foo(T t);
1080
1081 `-fno-nonnull-objects'
1082      Don't assume that a reference is initialized to refer to a valid
1083      object.  Although the current C++ Working Paper prohibits null
1084      references, some old code may rely on them, and you can use
1085      `-fno-nonnull-objects' to turn on checking.
1086
1087      At the moment, the compiler only does this checking for
1088      conversions to virtual base classes.
1089
1090 `-foperator-names'
1091      Recognize the operator name keywords `and', `bitand', `bitor',
1092      `compl', `not', `or' and `xor' as synonyms for the symbols they
1093      refer to.  `-ansi' implies `-foperator-names'.
1094
1095 `-fthis-is-variable'
1096      Permit assignment to `this'.  The incorporation of user-defined
1097      free store management into C++ has made assignment to `this' an
1098      anachronism.  Therefore, by default it is invalid to assign to
1099      `this' within a class member function; that is, GNU C++ treats
1100      `this' in a member function of class `X' as a non-lvalue of type
1101      `X *'.  However, for backwards compatibility, you can make it
1102      valid with `-fthis-is-variable'.
1103
1104 `-fvtable-thunks'
1105      Use `thunks' to implement the virtual function dispatch table
1106      (`vtable').  The traditional (cfront-style) approach to
1107      implementing vtables was to store a pointer to the function and two
1108      offsets for adjusting the `this' pointer at the call site.  Newer
1109      implementations store a single pointer to a `thunk' function which
1110      does any necessary adjustment and then calls the target function.
1111
1112      This option also enables a heuristic for controlling emission of
1113      vtables; if a class has any non-inline virtual functions, the
1114      vtable will be emitted in the translation unit containing the
1115      first one of those.
1116
1117 `-ftemplate-depth-N'
1118      Set the maximum instantiation depth for template classes to N.  A
1119      limit on the template instantiation depth is needed to detect
1120      endless recursions during template class instantiation. ANSI/ISO
1121      C++ conforming programs must not rely on a maximum depth greater
1122      than 17.
1123
1124 `-nostdinc++'
1125      Do not search for header files in the standard directories
1126      specific to C++, but do still search the other standard
1127      directories.  (This option is used when building libg++.)
1128
1129 `-traditional'
1130      For C++ programs (in addition to the effects that apply to both C
1131      and C++), this has the same effect as `-fthis-is-variable'.  *Note
1132      Options Controlling C Dialect: C Dialect Options.
1133
1134    In addition, these optimization, warning, and code generation options
1135 have meanings only for C++ programs:
1136
1137 `-fno-default-inline'
1138      Do not assume `inline' for functions defined inside a class scope.
1139      *Note Options That Control Optimization: Optimize Options.
1140
1141 `-Woverloaded-virtual'
1142 `-Wtemplate-debugging'
1143      Warnings that apply only to C++ programs.  *Note Options to
1144      Request or Suppress Warnings: Warning Options.
1145
1146 `-Weffc++'
1147      Warn about violation of some style rules from Effective C++ by
1148      Scott Myers.
1149
1150 `+eN'
1151      Control how virtual function definitions are used, in a fashion
1152      compatible with `cfront' 1.x.  *Note Options for Code Generation
1153      Conventions: Code Gen Options.
1154