OSDN Git Service

* doc/cppinternals.texi, doc/install.texi, doc/invoke.texi,
[pf3gnuchains/gcc-fork.git] / gcc / doc / invoke.texi
1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2 @c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
5
6 @ignore
7 @c man begin COPYRIGHT
8 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
9 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
10
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.2 or
13 any later version published by the Free Software Foundation; with the
14 Invariant Sections being ``GNU General Public License'' and ``Funding
15 Free Software'', the Front-Cover texts being (a) (see below), and with
16 the Back-Cover Texts being (b) (see below).  A copy of the license is
17 included in the gfdl(7) man page.
18
19 (a) The FSF's Front-Cover Text is:
20
21      A GNU Manual
22
23 (b) The FSF's Back-Cover Text is:
24
25      You have freedom to copy and modify this GNU Manual, like GNU
26      software.  Copies published by the Free Software Foundation raise
27      funds for GNU development.
28 @c man end
29 @c Set file name and title for the man page.
30 @setfilename gcc
31 @settitle GNU project C and C++ compiler
32 @c man begin SYNOPSIS
33 gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
34     [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
35     [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
36     [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
37     [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
38     [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
39     [@option{-o} @var{outfile}] @var{infile}@dots{}
40
41 Only the most useful options are listed here; see below for the
42 remainder.  @samp{g++} accepts mostly the same options as @samp{gcc}.
43 @c man end
44 @c man begin SEEALSO
45 gpl(7), gfdl(7), fsf-funding(7),
46 cpp(1), gcov(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
47 and the Info entries for @file{gcc}, @file{cpp}, @file{as},
48 @file{ld}, @file{binutils} and @file{gdb}.
49 @c man end
50 @c man begin BUGS
51 For instructions on reporting bugs, see
52 @w{@uref{http://gcc.gnu.org/bugs.html}}.  Use of the @command{gccbug}
53 script to report bugs is recommended.
54 @c man end
55 @c man begin AUTHOR
56 See the Info entry for @command{gcc}, or
57 @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
58 for contributors to GCC@.
59 @c man end
60 @end ignore
61
62 @node Invoking GCC
63 @chapter GCC Command Options
64 @cindex GCC command options
65 @cindex command options
66 @cindex options, GCC command
67
68 @c man begin DESCRIPTION
69 When you invoke GCC, it normally does preprocessing, compilation,
70 assembly and linking.  The ``overall options'' allow you to stop this
71 process at an intermediate stage.  For example, the @option{-c} option
72 says not to run the linker.  Then the output consists of object files
73 output by the assembler.
74
75 Other options are passed on to one stage of processing.  Some options
76 control the preprocessor and others the compiler itself.  Yet other
77 options control the assembler and linker; most of these are not
78 documented here, since you rarely need to use any of them.
79
80 @cindex C compilation options
81 Most of the command line options that you can use with GCC are useful
82 for C programs; when an option is only useful with another language
83 (usually C++), the explanation says so explicitly.  If the description
84 for a particular option does not mention a source language, you can use
85 that option with all supported languages.
86
87 @cindex C++ compilation options
88 @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
89 options for compiling C++ programs.
90
91 @cindex grouping options
92 @cindex options, grouping
93 The @command{gcc} program accepts options and file names as operands.  Many
94 options have multi-letter names; therefore multiple single-letter options
95 may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d
96 -r}}.
97
98 @cindex order of options
99 @cindex options, order
100 You can mix options and other arguments.  For the most part, the order
101 you use doesn't matter.  Order does matter when you use several options
102 of the same kind; for example, if you specify @option{-L} more than once,
103 the directories are searched in the order specified.
104
105 Many options have long names starting with @samp{-f} or with
106 @samp{-W}---for example, @option{-fforce-mem},
107 @option{-fstrength-reduce}, @option{-Wformat} and so on.  Most of
108 these have both positive and negative forms; the negative form of
109 @option{-ffoo} would be @option{-fno-foo}.  This manual documents
110 only one of these two forms, whichever one is not the default.
111
112 @c man end
113
114 @xref{Option Index}, for an index to GCC's options.
115
116 @menu
117 * Option Summary::      Brief list of all options, without explanations.
118 * Overall Options::     Controlling the kind of output:
119                         an executable, object files, assembler files,
120                         or preprocessed source.
121 * Invoking G++::        Compiling C++ programs.
122 * C Dialect Options::   Controlling the variant of C language compiled.
123 * C++ Dialect Options:: Variations on C++.
124 * Objective-C Dialect Options:: Variations on Objective-C.
125 * Language Independent Options:: Controlling how diagnostics should be
126                         formatted.
127 * Warning Options::     How picky should the compiler be?
128 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
129 * Optimize Options::    How much optimization?
130 * Preprocessor Options:: Controlling header files and macro definitions.
131                          Also, getting dependency information for Make.
132 * Assembler Options::   Passing options to the assembler.
133 * Link Options::        Specifying libraries and so on.
134 * Directory Options::   Where to find header files and libraries.
135                         Where to find the compiler executable files.
136 * Spec Files::          How to pass switches to sub-processes.
137 * Target Options::      Running a cross-compiler, or an old version of GCC.
138 * Submodel Options::    Specifying minor hardware or convention variations,
139                         such as 68010 vs 68020.
140 * Code Gen Options::    Specifying conventions for function calls, data layout
141                         and register usage.
142 * Environment Variables:: Env vars that affect GCC.
143 * Precompiled Headers:: Compiling a header once, and using it many times.
144 * Running Protoize::    Automatically adding or removing function prototypes.
145 @end menu
146
147 @c man begin OPTIONS
148
149 @node Option Summary
150 @section Option Summary
151
152 Here is a summary of all the options, grouped by type.  Explanations are
153 in the following sections.
154
155 @table @emph
156 @item Overall Options
157 @xref{Overall Options,,Options Controlling the Kind of Output}.
158 @gccoptlist{-c  -S  -E  -o @var{file}  -combine -pipe  -pass-exit-codes  @gol
159 -x @var{language}  -v  -###  --help  --target-help  --version}
160
161 @item C Language Options
162 @xref{C Dialect Options,,Options Controlling C Dialect}.
163 @gccoptlist{-ansi  -std=@var{standard}  -aux-info @var{filename} @gol
164 -fno-asm  -fno-builtin  -fno-builtin-@var{function} @gol
165 -fhosted  -ffreestanding  -fms-extensions @gol
166 -trigraphs  -no-integrated-cpp  -traditional  -traditional-cpp @gol
167 -fallow-single-precision  -fcond-mismatch @gol
168 -fsigned-bitfields  -fsigned-char @gol
169 -funsigned-bitfields  -funsigned-char}
170
171 @item C++ Language Options
172 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
173 @gccoptlist{-fabi-version=@var{n}  -fno-access-control  -fcheck-new @gol
174 -fconserve-space  -fno-const-strings @gol
175 -fno-elide-constructors @gol
176 -fno-enforce-eh-specs @gol
177 -ffor-scope  -fno-for-scope  -fno-gnu-keywords @gol
178 -fno-implicit-templates @gol
179 -fno-implicit-inline-templates @gol
180 -fno-implement-inlines  -fms-extensions @gol
181 -fno-nonansi-builtins  -fno-operator-names @gol
182 -fno-optional-diags  -fpermissive @gol
183 -frepo  -fno-rtti  -fstats  -ftemplate-depth-@var{n} @gol
184 -fuse-cxa-atexit  -fno-weak  -nostdinc++ @gol
185 -fno-default-inline  -Wabi  -Wctor-dtor-privacy @gol
186 -Wnon-virtual-dtor  -Wreorder @gol
187 -Weffc++  -Wno-deprecated @gol
188 -Wno-non-template-friend  -Wold-style-cast @gol
189 -Woverloaded-virtual  -Wno-pmf-conversions @gol
190 -Wsign-promo  -Wsynth}
191
192 @item Objective-C Language Options
193 @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}.
194 @gccoptlist{
195 -fconstant-string-class=@var{class-name} @gol
196 -fgnu-runtime  -fnext-runtime @gol
197 -fno-nil-receivers @gol
198 -fobjc-exceptions @gol
199 -freplace-objc-classes @gol
200 -fzero-link @gol
201 -gen-decls @gol
202 -Wno-protocol  -Wselector -Wundeclared-selector}
203
204 @item Language Independent Options
205 @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
206 @gccoptlist{-fmessage-length=@var{n}  @gol
207 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}}
208
209 @item Warning Options
210 @xref{Warning Options,,Options to Request or Suppress Warnings}.
211 @gccoptlist{-fsyntax-only  -pedantic  -pedantic-errors @gol
212 -w  -Wextra  -Wall  -Waggregate-return @gol
213 -Wcast-align  -Wcast-qual  -Wchar-subscripts  -Wcomment @gol
214 -Wconversion  -Wno-deprecated-declarations @gol
215 -Wdisabled-optimization  -Wno-div-by-zero  -Wendif-labels @gol
216 -Werror  -Werror-implicit-function-declaration @gol
217 -Wfatal-errors  -Wfloat-equal  -Wformat  -Wformat=2 @gol
218 -Wno-format-extra-args -Wformat-nonliteral @gol
219 -Wformat-security  -Wformat-y2k @gol
220 -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int @gol
221 -Wimport  -Wno-import  -Winit-self  -Winline @gol
222 -Wno-invalid-offsetof  -Winvalid-pch @gol
223 -Wlarger-than-@var{len}  -Wlong-long @gol
224 -Wmain  -Wmissing-braces @gol
225 -Wmissing-format-attribute  -Wmissing-include-dirs @gol
226 -Wmissing-noreturn @gol
227 -Wno-multichar  -Wnonnull  -Wpacked  -Wpadded @gol
228 -Wparentheses  -Wpointer-arith  -Wredundant-decls @gol
229 -Wreturn-type  -Wsequence-point  -Wshadow @gol
230 -Wsign-compare  -Wstrict-aliasing -Wstrict-aliasing=2 @gol
231 -Wswitch  -Wswitch-default  -Wswitch-enum @gol
232 -Wsystem-headers  -Wtrigraphs  -Wundef  -Wuninitialized @gol
233 -Wunknown-pragmas  -Wunreachable-code @gol
234 -Wunused  -Wunused-function  -Wunused-label  -Wunused-parameter @gol
235 -Wunused-value  -Wunused-variable  -Wwrite-strings @gol
236 -Wvariadic-macros}
237
238 @item C-only Warning Options
239 @gccoptlist{-Wbad-function-cast  -Wmissing-declarations @gol
240 -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition @gol
241 -Wstrict-prototypes  -Wtraditional @gol
242 -Wdeclaration-after-statement}
243
244 @item Debugging Options
245 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
246 @gccoptlist{-d@var{letters}  -dumpspecs  -dumpmachine  -dumpversion @gol
247 -fdump-unnumbered  -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
248 -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
249 -fdump-tree-all @gol
250 -fdump-tree-original@r{[}-@var{n}@r{]}  @gol
251 -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
252 -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
253 -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias @gol
254 -fdump-tree-ch @gol
255 -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
256 -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
257 -fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol
258 -fdump-tree-dom@r{[}-@var{n}@r{]} @gol
259 -fdump-tree-dse@r{[}-@var{n}@r{]} @gol
260 -fdump-tree-phiopt@r{[}-@var{n}@r{]} @gol
261 -fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol
262 -fdump-tree-copyrename@r{[}-@var{n}@r{]} @gol
263 -fdump-tree-nrv @gol
264 -fdump-tree-sra@r{[}-@var{n}@r{]} @gol
265 -fdump-tree-fre@r{[}-@var{n}@r{]} @gol
266 -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
267 -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs -ftree-based-profiling @gol
268 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
269 -ftest-coverage  -ftime-report -fvar-tracking @gol
270 -g  -g@var{level}  -gcoff -gdwarf-2 @gol
271 -ggdb  -gstabs  -gstabs+  -gvms  -gxcoff  -gxcoff+ @gol
272 -p  -pg  -print-file-name=@var{library}  -print-libgcc-file-name @gol
273 -print-multi-directory  -print-multi-lib @gol
274 -print-prog-name=@var{program}  -print-search-dirs  -Q @gol
275 -save-temps  -time}
276
277 @item Optimization Options
278 @xref{Optimize Options,,Options that Control Optimization}.
279 @gccoptlist{-falign-functions=@var{n}  -falign-jumps=@var{n} @gol
280 -falign-labels=@var{n}  -falign-loops=@var{n}  @gol
281 -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
282 -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
283 -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
284 -fcaller-saves  -fcprop-registers @gol
285 -fcse-follow-jumps  -fcse-skip-blocks  -fdata-sections @gol
286 -fdelayed-branch  -fdelete-null-pointer-checks @gol
287 -fexpensive-optimizations  -ffast-math  -ffloat-store @gol
288 -fforce-addr  -fforce-mem  -ffunction-sections @gol
289 -fgcse  -fgcse-lm  -fgcse-sm  -fgcse-las  -fgcse-after-reload @gol
290 -floop-optimize -fcrossjumping  -fif-conversion  -fif-conversion2 @gol
291 -finline-functions  -finline-limit=@var{n}  -fkeep-inline-functions @gol
292 -fkeep-static-consts  -fmerge-constants  -fmerge-all-constants @gol
293 -fmodulo-sched -fmove-all-movables  -fnew-ra  -fno-branch-count-reg @gol
294 -fno-default-inline  -fno-defer-pop -floop-optimize2 -fmove-loop-invariants @gol
295 -fno-function-cse  -fno-guess-branch-probability @gol
296 -fno-inline  -fno-math-errno  -fno-peephole  -fno-peephole2 @gol
297 -funsafe-math-optimizations  -ffinite-math-only @gol
298 -fno-trapping-math  -fno-zero-initialized-in-bss @gol
299 -fomit-frame-pointer  -foptimize-register-move @gol
300 -foptimize-sibling-calls  -fprefetch-loop-arrays @gol
301 -fprofile-generate -fprofile-use @gol
302 -freduce-all-givs  -fregmove  -frename-registers @gol
303 -freorder-blocks  -freorder-blocks-and-partition -freorder-functions @gol
304 -frerun-cse-after-loop  -frerun-loop-opt @gol
305 -frounding-math -fschedule-insns  -fschedule-insns2 @gol
306 -fno-sched-interblock  -fno-sched-spec  -fsched-spec-load @gol
307 -fsched-spec-load-dangerous  @gol
308 -fsched-stalled-insns=@var{n} -sched-stalled-insns-dep=@var{n} @gol
309 -fsched2-use-superblocks @gol
310 -fsched2-use-traces  -fsignaling-nans @gol
311 -fsingle-precision-constant  @gol
312 -fstrength-reduce  -fstrict-aliasing  -ftracer  -fthread-jumps @gol
313 -funroll-all-loops  -funroll-loops  -fpeel-loops @gol
314 -funswitch-loops  -fold-unroll-loops  -fold-unroll-all-loops @gol
315 -ftree-pre  -ftree-ccp  -ftree-dce -ftree-loop-optimize @gol
316 -ftree-dominator-opts -ftree-dse -ftree-copyrename @gol
317 -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre @gol
318 --param @var{name}=@var{value}
319 -O  -O0  -O1  -O2  -O3  -Os}
320
321 @item Preprocessor Options
322 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
323 @gccoptlist{-A@var{question}=@var{answer} @gol
324 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
325 -C  -dD  -dI  -dM  -dN @gol
326 -D@var{macro}@r{[}=@var{defn}@r{]}  -E  -H @gol
327 -idirafter @var{dir} @gol
328 -include @var{file}  -imacros @var{file} @gol
329 -iprefix @var{file}  -iwithprefix @var{dir} @gol
330 -iwithprefixbefore @var{dir}  -isystem @var{dir} @gol
331 -M  -MM  -MF  -MG  -MP  -MQ  -MT  -nostdinc  @gol
332 -P  -fworking-directory  -remap @gol
333 -trigraphs  -undef  -U@var{macro}  -Wp,@var{option} @gol
334 -Xpreprocessor @var{option}}
335
336 @item Assembler Option
337 @xref{Assembler Options,,Passing Options to the Assembler}.
338 @gccoptlist{-Wa,@var{option}  -Xassembler @var{option}}
339
340 @item Linker Options
341 @xref{Link Options,,Options for Linking}.
342 @gccoptlist{@var{object-file-name}  -l@var{library} @gol
343 -nostartfiles  -nodefaultlibs  -nostdlib -pie @gol
344 -s  -static  -static-libgcc  -shared  -shared-libgcc  -symbolic @gol
345 -Wl,@var{option}  -Xlinker @var{option} @gol
346 -u @var{symbol}}
347
348 @item Directory Options
349 @xref{Directory Options,,Options for Directory Search}.
350 @gccoptlist{-B@var{prefix}  -I@var{dir}  -iquote@var{dir}  -L@var{dir}  -specs=@var{file}  -I-}
351
352 @item Target Options
353 @c I wrote this xref this way to avoid overfull hbox. -- rms
354 @xref{Target Options}.
355 @gccoptlist{-V @var{version}  -b @var{machine}}
356
357 @item Machine Dependent Options
358 @xref{Submodel Options,,Hardware Models and Configurations}.
359 @c This list is ordered alphanumerically by subsection name.
360 @c Try and put the significant identifier (CPU or system) first,
361 @c so users have a clue at guessing where the ones they want will be.
362
363 @emph{ARC Options}
364 @gccoptlist{-EB  -EL @gol
365 -mmangle-cpu  -mcpu=@var{cpu}  -mtext=@var{text-section} @gol
366 -mdata=@var{data-section}  -mrodata=@var{readonly-data-section}}
367
368 @emph{ARM Options}
369 @gccoptlist{-mapcs-frame  -mno-apcs-frame @gol
370 -mabi=@var{name} @gol
371 -mapcs-stack-check  -mno-apcs-stack-check @gol
372 -mapcs-float  -mno-apcs-float @gol
373 -mapcs-reentrant  -mno-apcs-reentrant @gol
374 -msched-prolog  -mno-sched-prolog @gol
375 -mlittle-endian  -mbig-endian  -mwords-little-endian @gol
376 -mfloat-abi=@var{name}  -msoft-float  -mhard-float  -mfpe @gol
377 -mthumb-interwork  -mno-thumb-interwork @gol
378 -mcpu=@var{name}  -march=@var{name}  -mfpu=@var{name}  @gol
379 -mstructure-size-boundary=@var{n} @gol
380 -mabort-on-noreturn @gol
381 -mlong-calls  -mno-long-calls @gol
382 -msingle-pic-base  -mno-single-pic-base @gol
383 -mpic-register=@var{reg} @gol
384 -mnop-fun-dllimport @gol
385 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
386 -mpoke-function-name @gol
387 -mthumb  -marm @gol
388 -mtpcs-frame  -mtpcs-leaf-frame @gol
389 -mcaller-super-interworking  -mcallee-super-interworking}
390
391 @emph{AVR Options}
392 @gccoptlist{-mmcu=@var{mcu}  -msize  -minit-stack=@var{n}  -mno-interrupts @gol
393 -mcall-prologues  -mno-tablejump  -mtiny-stack  -mint8}
394
395 @emph{CRIS Options}
396 @gccoptlist{-mcpu=@var{cpu}  -march=@var{cpu}  -mtune=@var{cpu} @gol
397 -mmax-stack-frame=@var{n}  -melinux-stacksize=@var{n} @gol
398 -metrax4  -metrax100  -mpdebug  -mcc-init  -mno-side-effects @gol
399 -mstack-align  -mdata-align  -mconst-align @gol
400 -m32-bit  -m16-bit  -m8-bit  -mno-prologue-epilogue  -mno-gotplt @gol
401 -melf  -maout  -melinux  -mlinux  -sim  -sim2 @gol
402 -mmul-bug-workaround  -mno-mul-bug-workaround}
403
404 @emph{Darwin Options}
405 @gccoptlist{-all_load  -allowable_client  -arch  -arch_errors_fatal @gol
406 -arch_only  -bind_at_load  -bundle  -bundle_loader @gol
407 -client_name  -compatibility_version  -current_version @gol
408 -dependency-file  -dylib_file  -dylinker_install_name @gol
409 -dynamic  -dynamiclib  -exported_symbols_list @gol
410 -filelist  -flat_namespace  -force_cpusubtype_ALL @gol
411 -force_flat_namespace  -headerpad_max_install_names @gol
412 -image_base  -init  -install_name  -keep_private_externs @gol
413 -multi_module  -multiply_defined  -multiply_defined_unused @gol
414 -noall_load  -nofixprebinding -nomultidefs  -noprebind  -noseglinkedit @gol
415 -pagezero_size  -prebind  -prebind_all_twolevel_modules @gol
416 -private_bundle  -read_only_relocs  -sectalign @gol
417 -sectobjectsymbols  -whyload  -seg1addr @gol
418 -sectcreate  -sectobjectsymbols  -sectorder @gol
419 -seg_addr_table  -seg_addr_table_filename  -seglinkedit @gol
420 -segprot  -segs_read_only_addr  -segs_read_write_addr @gol
421 -single_module  -static  -sub_library  -sub_umbrella @gol
422 -twolevel_namespace  -umbrella  -undefined @gol
423 -unexported_symbols_list  -weak_reference_mismatches @gol
424 -whatsloaded -F}
425
426 @emph{DEC Alpha Options}
427 @gccoptlist{-mno-fp-regs  -msoft-float  -malpha-as  -mgas @gol
428 -mieee  -mieee-with-inexact  -mieee-conformant @gol
429 -mfp-trap-mode=@var{mode}  -mfp-rounding-mode=@var{mode} @gol
430 -mtrap-precision=@var{mode}  -mbuild-constants @gol
431 -mcpu=@var{cpu-type}  -mtune=@var{cpu-type} @gol
432 -mbwx  -mmax  -mfix  -mcix @gol
433 -mfloat-vax  -mfloat-ieee @gol
434 -mexplicit-relocs  -msmall-data  -mlarge-data @gol
435 -msmall-text  -mlarge-text @gol
436 -mmemory-latency=@var{time}}
437
438 @emph{DEC Alpha/VMS Options}
439 @gccoptlist{-mvms-return-codes}
440
441 @emph{FRV Options}
442 @gccoptlist{-mgpr-32  -mgpr-64  -mfpr-32  -mfpr-64 @gol
443 -mhard-float  -msoft-float @gol
444 -malloc-cc  -mfixed-cc  -mdword  -mno-dword @gol
445 -mdouble  -mno-double @gol
446 -mmedia  -mno-media  -mmuladd  -mno-muladd @gol
447 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp @gol
448 -mlibrary-pic  -macc-4 -macc-8 @gol
449 -mpack  -mno-pack  -mno-eflags  -mcond-move  -mno-cond-move @gol
450 -mscc  -mno-scc  -mcond-exec  -mno-cond-exec @gol
451 -mvliw-branch  -mno-vliw-branch @gol
452 -mmulti-cond-exec  -mno-multi-cond-exec  -mnested-cond-exec @gol
453 -mno-nested-cond-exec  -mtomcat-stats @gol
454 -mcpu=@var{cpu}}
455
456 @emph{H8/300 Options}
457 @gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
458
459 @emph{HPPA Options}
460 @gccoptlist{-march=@var{architecture-type} @gol
461 -mbig-switch  -mdisable-fpregs  -mdisable-indexing @gol
462 -mfast-indirect-calls  -mgas  -mgnu-ld   -mhp-ld @gol
463 -mjump-in-delay -mlinker-opt -mlong-calls @gol
464 -mlong-load-store  -mno-big-switch  -mno-disable-fpregs @gol
465 -mno-disable-indexing  -mno-fast-indirect-calls  -mno-gas @gol
466 -mno-jump-in-delay  -mno-long-load-store @gol
467 -mno-portable-runtime  -mno-soft-float @gol
468 -mno-space-regs  -msoft-float  -mpa-risc-1-0 @gol
469 -mpa-risc-1-1  -mpa-risc-2-0  -mportable-runtime @gol
470 -mschedule=@var{cpu-type}  -mspace-regs  -msio  -mwsio @gol
471 -nolibdld  -static  -threads}
472
473 @emph{i386 and x86-64 Options}
474 @gccoptlist{-mtune=@var{cpu-type}  -march=@var{cpu-type} @gol
475 -mfpmath=@var{unit} @gol
476 -masm=@var{dialect}  -mno-fancy-math-387 @gol
477 -mno-fp-ret-in-387  -msoft-float  -msvr3-shlib @gol
478 -mno-wide-multiply  -mrtd  -malign-double @gol
479 -mpreferred-stack-boundary=@var{num} @gol
480 -mmmx  -msse  -msse2 -msse3 -m3dnow @gol
481 -mthreads  -mno-align-stringops  -minline-all-stringops @gol
482 -mpush-args  -maccumulate-outgoing-args  -m128bit-long-double @gol
483 -m96bit-long-double  -mregparm=@var{num}  -momit-leaf-frame-pointer @gol
484 -mno-red-zone -mno-tls-direct-seg-refs @gol
485 -mcmodel=@var{code-model} @gol
486 -m32  -m64}
487
488 @emph{IA-64 Options}
489 @gccoptlist{-mbig-endian  -mlittle-endian  -mgnu-as  -mgnu-ld  -mno-pic @gol
490 -mvolatile-asm-stop  -mb-step  -mregister-names  -mno-sdata @gol
491 -mconstant-gp  -mauto-pic  -minline-float-divide-min-latency @gol
492 -minline-float-divide-max-throughput @gol
493 -minline-int-divide-min-latency @gol
494 -minline-int-divide-max-throughput  -mno-dwarf2-asm @gol
495 -mfixed-range=@var{register-range}}
496
497 @emph{M32R/D Options}
498 @gccoptlist{-m32r2 -m32rx -m32r @gol
499 -mdebug @gol
500 -malign-loops -mno-align-loops @gol
501 -missue-rate=@var{number} @gol
502 -mbranch-cost=@var{number} @gol
503 -mmodel=@var{code-size-model-type} @gol
504 -msdata=@var{sdata-type} @gol
505 -mno-flush-func -mflush-func=@var{name} @gol
506 -mno-flush-trap -mflush-trap=@var{number} @gol
507 -G @var{num}}
508
509 @emph{M680x0 Options}
510 @gccoptlist{-m68000  -m68020  -m68020-40  -m68020-60  -m68030  -m68040 @gol
511 -m68060  -mcpu32  -m5200  -m68881  -mbitfield  -mc68000  -mc68020   @gol
512 -mnobitfield  -mrtd  -mshort  -msoft-float  -mpcrel @gol
513 -malign-int  -mstrict-align  -msep-data  -mno-sep-data @gol
514 -mshared-library-id=n  -mid-shared-library  -mno-id-shared-library}
515
516 @emph{M68hc1x Options}
517 @gccoptlist{-m6811  -m6812  -m68hc11  -m68hc12   -m68hcs12 @gol
518 -mauto-incdec  -minmax  -mlong-calls  -mshort @gol
519 -msoft-reg-count=@var{count}}
520
521 @emph{MCore Options}
522 @gccoptlist{-mhardlit  -mno-hardlit  -mdiv  -mno-div  -mrelax-immediates @gol
523 -mno-relax-immediates  -mwide-bitfields  -mno-wide-bitfields @gol
524 -m4byte-functions  -mno-4byte-functions  -mcallgraph-data @gol
525 -mno-callgraph-data  -mslow-bytes  -mno-slow-bytes  -mno-lsim @gol
526 -mlittle-endian  -mbig-endian  -m210  -m340  -mstack-increment}
527
528 @emph{MIPS Options}
529 @gccoptlist{-EL  -EB  -march=@var{arch}  -mtune=@var{arch} @gol
530 -mips1  -mips2  -mips3  -mips4  -mips32  -mips32r2  -mips64 @gol
531 -mips16  -mno-mips16  -mabi=@var{abi}  -mabicalls  -mno-abicalls @gol
532 -mxgot  -mno-xgot  -mgp32  -mgp64  -mfp32  -mfp64 @gol
533 -mhard-float  -msoft-float  -msingle-float  -mdouble-float @gol
534 -mint64  -mlong64  -mlong32 @gol
535 -G@var{num}  -membedded-data  -mno-embedded-data @gol
536 -muninit-const-in-rodata  -mno-uninit-const-in-rodata @gol
537 -msplit-addresses  -mno-split-addresses  @gol
538 -mexplicit-relocs  -mno-explicit-relocs  @gol
539 -mrnames  -mno-rnames @gol
540 -mcheck-zero-division  -mno-check-zero-division @gol
541 -mmemcpy  -mno-memcpy  -mlong-calls  -mno-long-calls @gol
542 -mmad  -mno-mad  -mfused-madd  -mno-fused-madd  -nocpp @gol
543 -mfix-r4000  -mno-fix-r4000  -mfix-r4400  -mno-fix-r4400 @gol
544 -mfix-vr4120  -mno-fix-vr4120  -mfix-sb1  -mno-fix-sb1 @gol
545 -mflush-func=@var{func}  -mno-flush-func @gol
546 -mbranch-likely  -mno-branch-likely @gol
547 -mfp-exceptions -mno-fp-exceptions @gol
548 -mvr4130-align -mno-vr4130-align}
549
550 @emph{MMIX Options}
551 @gccoptlist{-mlibfuncs  -mno-libfuncs  -mepsilon  -mno-epsilon  -mabi=gnu @gol
552 -mabi=mmixware  -mzero-extend  -mknuthdiv  -mtoplevel-symbols @gol
553 -melf  -mbranch-predict  -mno-branch-predict  -mbase-addresses @gol
554 -mno-base-addresses  -msingle-exit  -mno-single-exit}
555
556 @emph{MN10300 Options}
557 @gccoptlist{-mmult-bug  -mno-mult-bug @gol
558 -mam33  -mno-am33 @gol
559 -mam33-2  -mno-am33-2 @gol
560 -mno-crt0  -mrelax}
561
562 @emph{NS32K Options}
563 @gccoptlist{-m32032  -m32332  -m32532  -m32081  -m32381 @gol
564 -mmult-add  -mnomult-add  -msoft-float  -mrtd  -mnortd @gol
565 -mregparam  -mnoregparam  -msb  -mnosb @gol
566 -mbitfield  -mnobitfield  -mhimem  -mnohimem}
567
568 @emph{PDP-11 Options}
569 @gccoptlist{-mfpu  -msoft-float  -mac0  -mno-ac0  -m40  -m45  -m10 @gol
570 -mbcopy  -mbcopy-builtin  -mint32  -mno-int16 @gol
571 -mint16  -mno-int32  -mfloat32  -mno-float64 @gol
572 -mfloat64  -mno-float32  -mabshi  -mno-abshi @gol
573 -mbranch-expensive  -mbranch-cheap @gol
574 -msplit  -mno-split  -munix-asm  -mdec-asm}
575
576 @emph{PowerPC Options}
577 See RS/6000 and PowerPC Options.
578
579 @emph{RS/6000 and PowerPC Options}
580 @gccoptlist{-mcpu=@var{cpu-type} @gol
581 -mtune=@var{cpu-type} @gol
582 -mpower  -mno-power  -mpower2  -mno-power2 @gol
583 -mpowerpc  -mpowerpc64  -mno-powerpc @gol
584 -maltivec  -mno-altivec @gol
585 -mpowerpc-gpopt  -mno-powerpc-gpopt @gol
586 -mpowerpc-gfxopt  -mno-powerpc-gfxopt @gol
587 -mnew-mnemonics  -mold-mnemonics @gol
588 -mfull-toc   -mminimal-toc  -mno-fp-in-toc  -mno-sum-in-toc @gol
589 -m64  -m32  -mxl-call  -mno-xl-call  -mpe @gol
590 -malign-power  -malign-natural @gol
591 -msoft-float  -mhard-float  -mmultiple  -mno-multiple @gol
592 -mstring  -mno-string  -mupdate  -mno-update @gol
593 -mfused-madd  -mno-fused-madd  -mbit-align  -mno-bit-align @gol
594 -mstrict-align  -mno-strict-align  -mrelocatable @gol
595 -mno-relocatable  -mrelocatable-lib  -mno-relocatable-lib @gol
596 -mtoc  -mno-toc  -mlittle  -mlittle-endian  -mbig  -mbig-endian @gol
597 -mdynamic-no-pic @gol
598 -mprioritize-restricted-insns=@var{priority} @gol
599 -msched-costly-dep=@var{dependence_type} @gol
600 -minsert-sched-nops=@var{scheme} @gol
601 -mcall-sysv  -mcall-netbsd @gol
602 -maix-struct-return  -msvr4-struct-return @gol
603 -mabi=altivec  -mabi=no-altivec @gol
604 -mabi=spe  -mabi=no-spe @gol
605 -misel=yes  -misel=no @gol
606 -mspe=yes  -mspe=no @gol
607 -mfloat-gprs=yes  -mfloat-gprs=no @gol
608 -mprototype  -mno-prototype @gol
609 -msim  -mmvme  -mads  -myellowknife  -memb  -msdata @gol
610 -msdata=@var{opt}  -mvxworks  -mwindiss  -G @var{num}  -pthread}
611
612 @emph{S/390 and zSeries Options}
613 @gccoptlist{-mtune=@var{cpu-type}  -march=@var{cpu-type} @gol
614 -mhard-float  -msoft-float  -mbackchain  -mno-backchain @gol
615 -msmall-exec  -mno-small-exec  -mmvcle -mno-mvcle @gol
616 -m64  -m31  -mdebug  -mno-debug  -mesa  -mzarch @gol
617 -mtpf-trace -mno-tpf-trace  -mfused-madd  -mno-fused-madd}
618
619 @emph{SH Options}
620 @gccoptlist{-m1  -m2  -m2e  -m3  -m3e @gol
621 -m4-nofpu  -m4-single-only  -m4-single  -m4 @gol
622 -m5-64media  -m5-64media-nofpu @gol
623 -m5-32media  -m5-32media-nofpu @gol
624 -m5-compact  -m5-compact-nofpu @gol
625 -mb  -ml  -mdalign  -mrelax @gol
626 -mbigtable  -mfmovd  -mhitachi  -mnomacsave @gol
627 -mieee  -misize  -mpadstruct  -mspace @gol
628 -mprefergot  -musermode}
629
630 @emph{SPARC Options}
631 @gccoptlist{-mcpu=@var{cpu-type} @gol
632 -mtune=@var{cpu-type} @gol
633 -mcmodel=@var{code-model} @gol
634 -m32  -m64  -mapp-regs  -mno-app-regs @gol
635 -mfaster-structs  -mno-faster-structs @gol
636 -mfpu  -mno-fpu  -mhard-float  -msoft-float @gol
637 -mhard-quad-float  -msoft-quad-float @gol
638 -mimpure-text  -mno-impure-text  -mlittle-endian @gol
639 -mstack-bias  -mno-stack-bias @gol
640 -munaligned-doubles  -mno-unaligned-doubles @gol
641 -mv8plus  -mno-v8plus  -mvis  -mno-vis}
642
643 @emph{System V Options}
644 @gccoptlist{-Qy  -Qn  -YP,@var{paths}  -Ym,@var{dir}}
645
646 @emph{TMS320C3x/C4x Options}
647 @gccoptlist{-mcpu=@var{cpu}  -mbig  -msmall  -mregparm  -mmemparm @gol
648 -mfast-fix  -mmpyi  -mbk  -mti  -mdp-isr-reload @gol
649 -mrpts=@var{count}  -mrptb  -mdb  -mloop-unsigned @gol
650 -mparallel-insns  -mparallel-mpy  -mpreserve-float}
651
652 @emph{V850 Options}
653 @gccoptlist{-mlong-calls  -mno-long-calls  -mep  -mno-ep @gol
654 -mprolog-function  -mno-prolog-function  -mspace @gol
655 -mtda=@var{n}  -msda=@var{n}  -mzda=@var{n} @gol
656 -mapp-regs  -mno-app-regs @gol
657 -mdisable-callt  -mno-disable-callt @gol
658 -mv850e1 @gol
659 -mv850e @gol
660 -mv850  -mbig-switch}
661
662 @emph{VAX Options}
663 @gccoptlist{-mg  -mgnu  -munix}
664
665 @emph{x86-64 Options}
666 See i386 and x86-64 Options.
667
668 @emph{Xstormy16 Options}
669 @gccoptlist{-msim}
670
671 @emph{Xtensa Options}
672 @gccoptlist{-mconst16 -mno-const16 @gol
673 -mfused-madd  -mno-fused-madd @gol
674 -mtext-section-literals  -mno-text-section-literals @gol
675 -mtarget-align  -mno-target-align @gol
676 -mlongcalls  -mno-longcalls}
677
678 @emph{zSeries Options}
679 See S/390 and zSeries Options.
680
681 @item Code Generation Options
682 @xref{Code Gen Options,,Options for Code Generation Conventions}.
683 @gccoptlist{-fcall-saved-@var{reg}  -fcall-used-@var{reg} @gol
684 -ffixed-@var{reg}  -fexceptions @gol
685 -fnon-call-exceptions  -funwind-tables @gol
686 -fasynchronous-unwind-tables @gol
687 -finhibit-size-directive  -finstrument-functions @gol
688 -fno-common  -fno-ident @gol
689 -fpcc-struct-return  -fpic  -fPIC -fpie -fPIE @gol
690 -freg-struct-return  -fshared-data  -fshort-enums @gol
691 -fshort-double  -fshort-wchar @gol
692 -fverbose-asm  -fpack-struct  -fstack-check @gol
693 -fstack-limit-register=@var{reg}  -fstack-limit-symbol=@var{sym} @gol
694 -fargument-alias  -fargument-noalias @gol
695 -fargument-noalias-global  -fleading-underscore @gol
696 -ftls-model=@var{model} @gol
697 -ftrapv  -fwrapv  -fbounds-check}
698 @end table
699
700 @menu
701 * Overall Options::     Controlling the kind of output:
702                         an executable, object files, assembler files,
703                         or preprocessed source.
704 * C Dialect Options::   Controlling the variant of C language compiled.
705 * C++ Dialect Options:: Variations on C++.
706 * Objective-C Dialect Options:: Variations on Objective-C.
707 * Language Independent Options:: Controlling how diagnostics should be
708                         formatted.
709 * Warning Options::     How picky should the compiler be?
710 * Debugging Options::   Symbol tables, measurements, and debugging dumps.
711 * Optimize Options::    How much optimization?
712 * Preprocessor Options:: Controlling header files and macro definitions.
713                          Also, getting dependency information for Make.
714 * Assembler Options::   Passing options to the assembler.
715 * Link Options::        Specifying libraries and so on.
716 * Directory Options::   Where to find header files and libraries.
717                         Where to find the compiler executable files.
718 * Spec Files::          How to pass switches to sub-processes.
719 * Target Options::      Running a cross-compiler, or an old version of GCC.
720 @end menu
721
722 @node Overall Options
723 @section Options Controlling the Kind of Output
724
725 Compilation can involve up to four stages: preprocessing, compilation
726 proper, assembly and linking, always in that order.  GCC is capable of
727 preprocessing and compiling several files either into several
728 assembler input files, or into one assembler input file; then each
729 assembler input file produces an object file, and linking combines all
730 the object files (those newly compiled, and those specified as input)
731 into an executable file.
732
733 @cindex file name suffix
734 For any given input file, the file name suffix determines what kind of
735 compilation is done:
736
737 @table @gcctabopt
738 @item @var{file}.c
739 C source code which must be preprocessed.
740
741 @item @var{file}.i
742 C source code which should not be preprocessed.
743
744 @item @var{file}.ii
745 C++ source code which should not be preprocessed.
746
747 @item @var{file}.m
748 Objective-C source code.  Note that you must link with the library
749 @file{libobjc.a} to make an Objective-C program work.
750
751 @item @var{file}.mi
752 Objective-C source code which should not be preprocessed.
753
754 @item @var{file}.h
755 C or C++ header file to be turned into a precompiled header.
756
757 @item @var{file}.cc
758 @itemx @var{file}.cp
759 @itemx @var{file}.cxx
760 @itemx @var{file}.cpp
761 @itemx @var{file}.CPP
762 @itemx @var{file}.c++
763 @itemx @var{file}.C
764 C++ source code which must be preprocessed.  Note that in @samp{.cxx},
765 the last two letters must both be literally @samp{x}.  Likewise,
766 @samp{.C} refers to a literal capital C@.
767
768 @item @var{file}.hh
769 @itemx @var{file}.H
770 C++ header file to be turned into a precompiled header.
771
772 @item @var{file}.f
773 @itemx @var{file}.for
774 @itemx @var{file}.FOR
775 Fortran source code which should not be preprocessed.
776
777 @item @var{file}.F
778 @itemx @var{file}.fpp
779 @itemx @var{file}.FPP
780 Fortran source code which must be preprocessed (with the traditional
781 preprocessor).
782
783 @item @var{file}.r
784 Fortran source code which must be preprocessed with a RATFOR
785 preprocessor (not included with GCC)@.
786
787 @item @var{file}.f90
788 @itemx @var{file}.f95
789 Fortran 90/95 source code which should not be preprocessed.
790
791 @c FIXME: Descriptions of Java file types.
792 @c @var{file}.java
793 @c @var{file}.class
794 @c @var{file}.zip
795 @c @var{file}.jar
796
797 @item @var{file}.ads
798 Ada source code file which contains a library unit declaration (a
799 declaration of a package, subprogram, or generic, or a generic
800 instantiation), or a library unit renaming declaration (a package,
801 generic, or subprogram renaming declaration).  Such files are also
802 called @dfn{specs}.
803
804 @itemx @var{file}.adb
805 Ada source code file containing a library unit body (a subprogram or
806 package body).  Such files are also called @dfn{bodies}.
807
808 @c GCC also knows about some suffixes for languages not yet included:
809 @c Pascal:
810 @c @var{file}.p
811 @c @var{file}.pas
812
813 @item @var{file}.s
814 Assembler code.
815
816 @item @var{file}.S
817 Assembler code which must be preprocessed.
818
819 @item @var{other}
820 An object file to be fed straight into linking.
821 Any file name with no recognized suffix is treated this way.
822 @end table
823
824 @opindex x
825 You can specify the input language explicitly with the @option{-x} option:
826
827 @table @gcctabopt
828 @item -x @var{language}
829 Specify explicitly the @var{language} for the following input files
830 (rather than letting the compiler choose a default based on the file
831 name suffix).  This option applies to all following input files until
832 the next @option{-x} option.  Possible values for @var{language} are:
833 @smallexample
834 c  c-header  cpp-output
835 c++  c++-header  c++-cpp-output
836 objective-c  objective-c-header  objc-cpp-output
837 assembler  assembler-with-cpp
838 ada
839 f77  f77-cpp-input  ratfor
840 f95
841 java
842 treelang
843 @end smallexample
844
845 @item -x none
846 Turn off any specification of a language, so that subsequent files are
847 handled according to their file name suffixes (as they are if @option{-x}
848 has not been used at all).
849
850 @item -pass-exit-codes
851 @opindex pass-exit-codes
852 Normally the @command{gcc} program will exit with the code of 1 if any
853 phase of the compiler returns a non-success return code.  If you specify
854 @option{-pass-exit-codes}, the @command{gcc} program will instead return with
855 numerically highest error produced by any phase that returned an error
856 indication.
857 @end table
858
859 If you only want some of the stages of compilation, you can use
860 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
861 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
862 @command{gcc} is to stop.  Note that some combinations (for example,
863 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
864
865 @table @gcctabopt
866 @item -c
867 @opindex c
868 Compile or assemble the source files, but do not link.  The linking
869 stage simply is not done.  The ultimate output is in the form of an
870 object file for each source file.
871
872 By default, the object file name for a source file is made by replacing
873 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
874
875 Unrecognized input files, not requiring compilation or assembly, are
876 ignored.
877
878 @item -S
879 @opindex S
880 Stop after the stage of compilation proper; do not assemble.  The output
881 is in the form of an assembler code file for each non-assembler input
882 file specified.
883
884 By default, the assembler file name for a source file is made by
885 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
886
887 Input files that don't require compilation are ignored.
888
889 @item -E
890 @opindex E
891 Stop after the preprocessing stage; do not run the compiler proper.  The
892 output is in the form of preprocessed source code, which is sent to the
893 standard output.
894
895 Input files which don't require preprocessing are ignored.
896
897 @cindex output file option
898 @item -o @var{file}
899 @opindex o
900 Place output in file @var{file}.  This applies regardless to whatever
901 sort of output is being produced, whether it be an executable file,
902 an object file, an assembler file or preprocessed C code.
903
904 If @option{-o} is not specified, the default is to put an executable
905 file in @file{a.out}, the object file for
906 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
907 assembler file in @file{@var{source}.s}, a precompiled header file in
908 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
909 standard output.
910
911 @item -v
912 @opindex v
913 Print (on standard error output) the commands executed to run the stages
914 of compilation.  Also print the version number of the compiler driver
915 program and of the preprocessor and the compiler proper.
916
917 @item -###
918 @opindex ###
919 Like @option{-v} except the commands are not executed and all command
920 arguments are quoted.  This is useful for shell scripts to capture the
921 driver-generated command lines.
922
923 @item -pipe
924 @opindex pipe
925 Use pipes rather than temporary files for communication between the
926 various stages of compilation.  This fails to work on some systems where
927 the assembler is unable to read from a pipe; but the GNU assembler has
928 no trouble.
929
930 @item -combine
931 @opindex combine
932 If you are compiling multiple source files, this option tells the driver
933 to pass all the source files to the compiler at once (for those
934 languages for which the compiler can handle this).  This will allow
935 intermodule analysis (IMA) to be performed by the compiler.  Currently the only
936 language for which this is supported is C.  If you pass source files for
937 multiple languages to the driver, using this option, the driver will invoke
938 the compiler(s) that support IMA once each, passing each compiler all the
939 source files appropriate for it.  For those languages that do not support
940 IMA this option will be ignored, and the compiler will be invoked once for
941 each source file in that language.  If you use this option in conjunction
942 with -save-temps, the compiler will generate multiple pre-processed files
943 (one for each source file), but only one (combined) .o or .s file.
944
945 @item --help
946 @opindex help
947 Print (on the standard output) a description of the command line options
948 understood by @command{gcc}.  If the @option{-v} option is also specified
949 then @option{--help} will also be passed on to the various processes
950 invoked by @command{gcc}, so that they can display the command line options
951 they accept.  If the @option{-Wextra} option is also specified then command
952 line options which have no documentation associated with them will also
953 be displayed.
954
955 @item --target-help
956 @opindex target-help
957 Print (on the standard output) a description of target specific command
958 line options for each tool.
959
960 @item --version
961 @opindex version
962 Display the version number and copyrights of the invoked GCC.
963 @end table
964
965 @node Invoking G++
966 @section Compiling C++ Programs
967
968 @cindex suffixes for C++ source
969 @cindex C++ source file suffixes
970 C++ source files conventionally use one of the suffixes @samp{.C},
971 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
972 @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and
973 preprocessed C++ files use the suffix @samp{.ii}.  GCC recognizes
974 files with these names and compiles them as C++ programs even if you
975 call the compiler the same way as for compiling C programs (usually
976 with the name @command{gcc}).
977
978 @findex g++
979 @findex c++
980 However, C++ programs often require class libraries as well as a
981 compiler that understands the C++ language---and under some
982 circumstances, you might want to compile programs or header files from
983 standard input, or otherwise without a suffix that flags them as C++
984 programs.  You might also like to precompile a C header file with a
985 @samp{.h} extension to be used in C++ compilations.  @command{g++} is a
986 program that calls GCC with the default language set to C++, and
987 automatically specifies linking against the C++ library.  On many
988 systems, @command{g++} is also installed with the name @command{c++}.
989
990 @cindex invoking @command{g++}
991 When you compile C++ programs, you may specify many of the same
992 command-line options that you use for compiling programs in any
993 language; or command-line options meaningful for C and related
994 languages; or options that are meaningful only for C++ programs.
995 @xref{C Dialect Options,,Options Controlling C Dialect}, for
996 explanations of options for languages related to C@.
997 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
998 explanations of options that are meaningful only for C++ programs.
999
1000 @node C Dialect Options
1001 @section Options Controlling C Dialect
1002 @cindex dialect options
1003 @cindex language dialect options
1004 @cindex options, dialect
1005
1006 The following options control the dialect of C (or languages derived
1007 from C, such as C++ and Objective-C) that the compiler accepts:
1008
1009 @table @gcctabopt
1010 @cindex ANSI support
1011 @cindex ISO support
1012 @item -ansi
1013 @opindex ansi
1014 In C mode, support all ISO C90 programs.  In C++ mode,
1015 remove GNU extensions that conflict with ISO C++.
1016
1017 This turns off certain features of GCC that are incompatible with ISO
1018 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
1019 such as the @code{asm} and @code{typeof} keywords, and
1020 predefined macros such as @code{unix} and @code{vax} that identify the
1021 type of system you are using.  It also enables the undesirable and
1022 rarely used ISO trigraph feature.  For the C compiler,
1023 it disables recognition of C++ style @samp{//} comments as well as
1024 the @code{inline} keyword.
1025
1026 The alternate keywords @code{__asm__}, @code{__extension__},
1027 @code{__inline__} and @code{__typeof__} continue to work despite
1028 @option{-ansi}.  You would not want to use them in an ISO C program, of
1029 course, but it is useful to put them in header files that might be included
1030 in compilations done with @option{-ansi}.  Alternate predefined macros
1031 such as @code{__unix__} and @code{__vax__} are also available, with or
1032 without @option{-ansi}.
1033
1034 The @option{-ansi} option does not cause non-ISO programs to be
1035 rejected gratuitously.  For that, @option{-pedantic} is required in
1036 addition to @option{-ansi}.  @xref{Warning Options}.
1037
1038 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
1039 option is used.  Some header files may notice this macro and refrain
1040 from declaring certain functions or defining certain macros that the
1041 ISO standard doesn't call for; this is to avoid interfering with any
1042 programs that might use these names for other things.
1043
1044 Functions which would normally be built in but do not have semantics
1045 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
1046 functions with @option{-ansi} is used.  @xref{Other Builtins,,Other
1047 built-in functions provided by GCC}, for details of the functions
1048 affected.
1049
1050 @item -std=
1051 @opindex std
1052 Determine the language standard.  This option is currently only
1053 supported when compiling C or C++.  A value for this option must be
1054 provided; possible values are
1055
1056 @table @samp
1057 @item c89
1058 @itemx iso9899:1990
1059 ISO C90 (same as @option{-ansi}).
1060
1061 @item iso9899:199409
1062 ISO C90 as modified in amendment 1.
1063
1064 @item c99
1065 @itemx c9x
1066 @itemx iso9899:1999
1067 @itemx iso9899:199x
1068 ISO C99.  Note that this standard is not yet fully supported; see
1069 @w{@uref{http://gcc.gnu.org/c99status.html}} for more information.  The
1070 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
1071
1072 @item gnu89
1073 Default, ISO C90 plus GNU extensions (including some C99 features).
1074
1075 @item gnu99
1076 @itemx gnu9x
1077 ISO C99 plus GNU extensions.  When ISO C99 is fully implemented in GCC,
1078 this will become the default.  The name @samp{gnu9x} is deprecated.
1079
1080 @item c++98
1081 The 1998 ISO C++ standard plus amendments.
1082
1083 @item gnu++98
1084 The same as @option{-std=c++98} plus GNU extensions.  This is the
1085 default for C++ code.
1086 @end table
1087
1088 Even when this option is not specified, you can still use some of the
1089 features of newer standards in so far as they do not conflict with
1090 previous C standards.  For example, you may use @code{__restrict__} even
1091 when @option{-std=c99} is not specified.
1092
1093 The @option{-std} options specifying some version of ISO C have the same
1094 effects as @option{-ansi}, except that features that were not in ISO C90
1095 but are in the specified version (for example, @samp{//} comments and
1096 the @code{inline} keyword in ISO C99) are not disabled.
1097
1098 @xref{Standards,,Language Standards Supported by GCC}, for details of
1099 these standard versions.
1100
1101 @item -aux-info @var{filename}
1102 @opindex aux-info
1103 Output to the given filename prototyped declarations for all functions
1104 declared and/or defined in a translation unit, including those in header
1105 files.  This option is silently ignored in any language other than C@.
1106
1107 Besides declarations, the file indicates, in comments, the origin of
1108 each declaration (source file and line), whether the declaration was
1109 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
1110 @samp{O} for old, respectively, in the first character after the line
1111 number and the colon), and whether it came from a declaration or a
1112 definition (@samp{C} or @samp{F}, respectively, in the following
1113 character).  In the case of function definitions, a K&R-style list of
1114 arguments followed by their declarations is also provided, inside
1115 comments, after the declaration.
1116
1117 @item -fno-asm
1118 @opindex fno-asm
1119 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
1120 keyword, so that code can use these words as identifiers.  You can use
1121 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
1122 instead.  @option{-ansi} implies @option{-fno-asm}.
1123
1124 In C++, this switch only affects the @code{typeof} keyword, since
1125 @code{asm} and @code{inline} are standard keywords.  You may want to
1126 use the @option{-fno-gnu-keywords} flag instead, which has the same
1127 effect.  In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
1128 switch only affects the @code{asm} and @code{typeof} keywords, since
1129 @code{inline} is a standard keyword in ISO C99.
1130
1131 @item -fno-builtin
1132 @itemx -fno-builtin-@var{function}
1133 @opindex fno-builtin
1134 @cindex built-in functions
1135 Don't recognize built-in functions that do not begin with
1136 @samp{__builtin_} as prefix.  @xref{Other Builtins,,Other built-in
1137 functions provided by GCC}, for details of the functions affected,
1138 including those which are not built-in functions when @option{-ansi} or
1139 @option{-std} options for strict ISO C conformance are used because they
1140 do not have an ISO standard meaning.
1141
1142 GCC normally generates special code to handle certain built-in functions
1143 more efficiently; for instance, calls to @code{alloca} may become single
1144 instructions that adjust the stack directly, and calls to @code{memcpy}
1145 may become inline copy loops.  The resulting code is often both smaller
1146 and faster, but since the function calls no longer appear as such, you
1147 cannot set a breakpoint on those calls, nor can you change the behavior
1148 of the functions by linking with a different library.
1149
1150 With the @option{-fno-builtin-@var{function}} option
1151 only the built-in function @var{function} is
1152 disabled.  @var{function} must not begin with @samp{__builtin_}.  If a
1153 function is named this is not built-in in this version of GCC, this
1154 option is ignored.  There is no corresponding
1155 @option{-fbuiltin-@var{function}} option; if you wish to enable
1156 built-in functions selectively when using @option{-fno-builtin} or
1157 @option{-ffreestanding}, you may define macros such as:
1158
1159 @smallexample
1160 #define abs(n)          __builtin_abs ((n))
1161 #define strcpy(d, s)    __builtin_strcpy ((d), (s))
1162 @end smallexample
1163
1164 @item -fhosted
1165 @opindex fhosted
1166 @cindex hosted environment
1167
1168 Assert that compilation takes place in a hosted environment.  This implies
1169 @option{-fbuiltin}.  A hosted environment is one in which the
1170 entire standard library is available, and in which @code{main} has a return
1171 type of @code{int}.  Examples are nearly everything except a kernel.
1172 This is equivalent to @option{-fno-freestanding}.
1173
1174 @item -ffreestanding
1175 @opindex ffreestanding
1176 @cindex hosted environment
1177
1178 Assert that compilation takes place in a freestanding environment.  This
1179 implies @option{-fno-builtin}.  A freestanding environment
1180 is one in which the standard library may not exist, and program startup may
1181 not necessarily be at @code{main}.  The most obvious example is an OS kernel.
1182 This is equivalent to @option{-fno-hosted}.
1183
1184 @xref{Standards,,Language Standards Supported by GCC}, for details of
1185 freestanding and hosted environments.
1186
1187 @item -fms-extensions
1188 @opindex fms-extensions
1189 Accept some non-standard constructs used in Microsoft header files.
1190
1191 @item -trigraphs
1192 @opindex trigraphs
1193 Support ISO C trigraphs.  The @option{-ansi} option (and @option{-std}
1194 options for strict ISO C conformance) implies @option{-trigraphs}.
1195
1196 @item -no-integrated-cpp
1197 @opindex no-integrated-cpp
1198 Performs a compilation in two passes: preprocessing and compiling.  This
1199 option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
1200 @option{-B} option. The user supplied compilation step can then add in
1201 an additional preprocessing step after normal preprocessing but before
1202 compiling. The default is to use the integrated cpp (internal cpp)
1203
1204 The semantics of this option will change if "cc1", "cc1plus", and
1205 "cc1obj" are merged.
1206
1207 @cindex traditional C language
1208 @cindex C language, traditional
1209 @item -traditional
1210 @itemx -traditional-cpp
1211 @opindex traditional-cpp
1212 @opindex traditional
1213 Formerly, these options caused GCC to attempt to emulate a pre-standard
1214 C compiler.  They are now only supported with the @option{-E} switch.
1215 The preprocessor continues to support a pre-standard mode.  See the GNU
1216 CPP manual for details.
1217
1218 @item -fcond-mismatch
1219 @opindex fcond-mismatch
1220 Allow conditional expressions with mismatched types in the second and
1221 third arguments.  The value of such an expression is void.  This option
1222 is not supported for C++.
1223
1224 @item -funsigned-char
1225 @opindex funsigned-char
1226 Let the type @code{char} be unsigned, like @code{unsigned char}.
1227
1228 Each kind of machine has a default for what @code{char} should
1229 be.  It is either like @code{unsigned char} by default or like
1230 @code{signed char} by default.
1231
1232 Ideally, a portable program should always use @code{signed char} or
1233 @code{unsigned char} when it depends on the signedness of an object.
1234 But many programs have been written to use plain @code{char} and
1235 expect it to be signed, or expect it to be unsigned, depending on the
1236 machines they were written for.  This option, and its inverse, let you
1237 make such a program work with the opposite default.
1238
1239 The type @code{char} is always a distinct type from each of
1240 @code{signed char} or @code{unsigned char}, even though its behavior
1241 is always just like one of those two.
1242
1243 @item -fsigned-char
1244 @opindex fsigned-char
1245 Let the type @code{char} be signed, like @code{signed char}.
1246
1247 Note that this is equivalent to @option{-fno-unsigned-char}, which is
1248 the negative form of @option{-funsigned-char}.  Likewise, the option
1249 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
1250
1251 @item -fsigned-bitfields
1252 @itemx -funsigned-bitfields
1253 @itemx -fno-signed-bitfields
1254 @itemx -fno-unsigned-bitfields
1255 @opindex fsigned-bitfields
1256 @opindex funsigned-bitfields
1257 @opindex fno-signed-bitfields
1258 @opindex fno-unsigned-bitfields
1259 These options control whether a bit-field is signed or unsigned, when the
1260 declaration does not use either @code{signed} or @code{unsigned}.  By
1261 default, such a bit-field is signed, because this is consistent: the
1262 basic integer types such as @code{int} are signed types.
1263 @end table
1264
1265 @node C++ Dialect Options
1266 @section Options Controlling C++ Dialect
1267
1268 @cindex compiler options, C++
1269 @cindex C++ options, command line
1270 @cindex options, C++
1271 This section describes the command-line options that are only meaningful
1272 for C++ programs; but you can also use most of the GNU compiler options
1273 regardless of what language your program is in.  For example, you
1274 might compile a file @code{firstClass.C} like this:
1275
1276 @smallexample
1277 g++ -g -frepo -O -c firstClass.C
1278 @end smallexample
1279
1280 @noindent
1281 In this example, only @option{-frepo} is an option meant
1282 only for C++ programs; you can use the other options with any
1283 language supported by GCC@.
1284
1285 Here is a list of options that are @emph{only} for compiling C++ programs:
1286
1287 @table @gcctabopt
1288
1289 @item -fabi-version=@var{n}
1290 @opindex fabi-version
1291 Use version @var{n} of the C++ ABI.  Version 2 is the version of the
1292 C++ ABI that first appeared in G++ 3.4.  Version 1 is the version of
1293 the C++ ABI that first appeared in G++ 3.2.  Version 0 will always be
1294 the version that conforms most closely to the C++ ABI specification.
1295 Therefore, the ABI obtained using version 0 will change as ABI bugs
1296 are fixed.
1297
1298 The default is version 2.
1299
1300 @item -fno-access-control
1301 @opindex fno-access-control
1302 Turn off all access checking.  This switch is mainly useful for working
1303 around bugs in the access control code.
1304
1305 @item -fcheck-new
1306 @opindex fcheck-new
1307 Check that the pointer returned by @code{operator new} is non-null
1308 before attempting to modify the storage allocated.  This check is
1309 normally unnecessary because the C++ standard specifies that
1310 @code{operator new} will only return @code{0} if it is declared
1311 @samp{throw()}, in which case the compiler will always check the
1312 return value even without this option.  In all other cases, when
1313 @code{operator new} has a non-empty exception specification, memory
1314 exhaustion is signalled by throwing @code{std::bad_alloc}.  See also
1315 @samp{new (nothrow)}.
1316
1317 @item -fconserve-space
1318 @opindex fconserve-space
1319 Put uninitialized or runtime-initialized global variables into the
1320 common segment, as C does.  This saves space in the executable at the
1321 cost of not diagnosing duplicate definitions.  If you compile with this
1322 flag and your program mysteriously crashes after @code{main()} has
1323 completed, you may have an object that is being destroyed twice because
1324 two definitions were merged.
1325
1326 This option is no longer useful on most targets, now that support has
1327 been added for putting variables into BSS without making them common.
1328
1329 @item -fno-const-strings
1330 @opindex fno-const-strings
1331 Give string constants type @code{char *} instead of type @code{const
1332 char *}.  By default, G++ uses type @code{const char *} as required by
1333 the standard.  Even if you use @option{-fno-const-strings}, you cannot
1334 actually modify the value of a string constant.
1335
1336 This option might be removed in a future release of G++.  For maximum
1337 portability, you should structure your code so that it works with
1338 string constants that have type @code{const char *}.
1339
1340 @item -fno-elide-constructors
1341 @opindex fno-elide-constructors
1342 The C++ standard allows an implementation to omit creating a temporary
1343 which is only used to initialize another object of the same type.
1344 Specifying this option disables that optimization, and forces G++ to
1345 call the copy constructor in all cases.
1346
1347 @item -fno-enforce-eh-specs
1348 @opindex fno-enforce-eh-specs
1349 Don't check for violation of exception specifications at runtime.  This
1350 option violates the C++ standard, but may be useful for reducing code
1351 size in production builds, much like defining @samp{NDEBUG}.  The compiler
1352 will still optimize based on the exception specifications.
1353
1354 @item -ffor-scope
1355 @itemx -fno-for-scope
1356 @opindex ffor-scope
1357 @opindex fno-for-scope
1358 If @option{-ffor-scope} is specified, the scope of variables declared in
1359 a @i{for-init-statement} is limited to the @samp{for} loop itself,
1360 as specified by the C++ standard.
1361 If @option{-fno-for-scope} is specified, the scope of variables declared in
1362 a @i{for-init-statement} extends to the end of the enclosing scope,
1363 as was the case in old versions of G++, and other (traditional)
1364 implementations of C++.
1365
1366 The default if neither flag is given to follow the standard,
1367 but to allow and give a warning for old-style code that would
1368 otherwise be invalid, or have different behavior.
1369
1370 @item -fno-gnu-keywords
1371 @opindex fno-gnu-keywords
1372 Do not recognize @code{typeof} as a keyword, so that code can use this
1373 word as an identifier.  You can use the keyword @code{__typeof__} instead.
1374 @option{-ansi} implies @option{-fno-gnu-keywords}.
1375
1376 @item -fno-implicit-templates
1377 @opindex fno-implicit-templates
1378 Never emit code for non-inline templates which are instantiated
1379 implicitly (i.e.@: by use); only emit code for explicit instantiations.
1380 @xref{Template Instantiation}, for more information.
1381
1382 @item -fno-implicit-inline-templates
1383 @opindex fno-implicit-inline-templates
1384 Don't emit code for implicit instantiations of inline templates, either.
1385 The default is to handle inlines differently so that compiles with and
1386 without optimization will need the same set of explicit instantiations.
1387
1388 @item -fno-implement-inlines
1389 @opindex fno-implement-inlines
1390 To save space, do not emit out-of-line copies of inline functions
1391 controlled by @samp{#pragma implementation}.  This will cause linker
1392 errors if these functions are not inlined everywhere they are called.
1393
1394 @item -fms-extensions
1395 @opindex fms-extensions
1396 Disable pedantic warnings about constructs used in MFC, such as implicit
1397 int and getting a pointer to member function via non-standard syntax.
1398
1399 @item -fno-nonansi-builtins
1400 @opindex fno-nonansi-builtins
1401 Disable built-in declarations of functions that are not mandated by
1402 ANSI/ISO C@.  These include @code{ffs}, @code{alloca}, @code{_exit},
1403 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
1404
1405 @item -fno-operator-names
1406 @opindex fno-operator-names
1407 Do not treat the operator name keywords @code{and}, @code{bitand},
1408 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1409 synonyms as keywords.
1410
1411 @item -fno-optional-diags
1412 @opindex fno-optional-diags
1413 Disable diagnostics that the standard says a compiler does not need to
1414 issue.  Currently, the only such diagnostic issued by G++ is the one for
1415 a name having multiple meanings within a class.
1416
1417 @item -fpermissive
1418 @opindex fpermissive
1419 Downgrade some diagnostics about nonconformant code from errors to
1420 warnings.  Thus, using @option{-fpermissive} will allow some
1421 nonconforming code to compile.
1422
1423 @item -frepo
1424 @opindex frepo
1425 Enable automatic template instantiation at link time.  This option also
1426 implies @option{-fno-implicit-templates}.  @xref{Template
1427 Instantiation}, for more information.
1428
1429 @item -fno-rtti
1430 @opindex fno-rtti
1431 Disable generation of information about every class with virtual
1432 functions for use by the C++ runtime type identification features
1433 (@samp{dynamic_cast} and @samp{typeid}).  If you don't use those parts
1434 of the language, you can save some space by using this flag.  Note that
1435 exception handling uses the same information, but it will generate it as
1436 needed.
1437
1438 @item -fstats
1439 @opindex fstats
1440 Emit statistics about front-end processing at the end of the compilation.
1441 This information is generally only useful to the G++ development team.
1442
1443 @item -ftemplate-depth-@var{n}
1444 @opindex ftemplate-depth
1445 Set the maximum instantiation depth for template classes to @var{n}.
1446 A limit on the template instantiation depth is needed to detect
1447 endless recursions during template class instantiation.  ANSI/ISO C++
1448 conforming programs must not rely on a maximum depth greater than 17.
1449
1450 @item -fuse-cxa-atexit
1451 @opindex fuse-cxa-atexit
1452 Register destructors for objects with static storage duration with the
1453 @code{__cxa_atexit} function rather than the @code{atexit} function.
1454 This option is required for fully standards-compliant handling of static
1455 destructors, but will only work if your C library supports
1456 @code{__cxa_atexit}.
1457
1458 @item -fno-weak
1459 @opindex fno-weak
1460 Do not use weak symbol support, even if it is provided by the linker.
1461 By default, G++ will use weak symbols if they are available.  This
1462 option exists only for testing, and should not be used by end-users;
1463 it will result in inferior code and has no benefits.  This option may
1464 be removed in a future release of G++.
1465
1466 @item -nostdinc++
1467 @opindex nostdinc++
1468 Do not search for header files in the standard directories specific to
1469 C++, but do still search the other standard directories.  (This option
1470 is used when building the C++ library.)
1471 @end table
1472
1473 In addition, these optimization, warning, and code generation options
1474 have meanings only for C++ programs:
1475
1476 @table @gcctabopt
1477 @item -fno-default-inline
1478 @opindex fno-default-inline
1479 Do not assume @samp{inline} for functions defined inside a class scope.
1480 @xref{Optimize Options,,Options That Control Optimization}.  Note that these
1481 functions will have linkage like inline functions; they just won't be
1482 inlined by default.
1483
1484 @item -Wabi @r{(C++ only)}
1485 @opindex Wabi
1486 Warn when G++ generates code that is probably not compatible with the
1487 vendor-neutral C++ ABI.  Although an effort has been made to warn about
1488 all such cases, there are probably some cases that are not warned about,
1489 even though G++ is generating incompatible code.  There may also be
1490 cases where warnings are emitted even though the code that is generated
1491 will be compatible.
1492
1493 You should rewrite your code to avoid these warnings if you are
1494 concerned about the fact that code generated by G++ may not be binary
1495 compatible with code generated by other compilers.
1496
1497 The known incompatibilities at this point include:
1498
1499 @itemize @bullet
1500
1501 @item
1502 Incorrect handling of tail-padding for bit-fields.  G++ may attempt to
1503 pack data into the same byte as a base class.  For example:
1504
1505 @smallexample
1506 struct A @{ virtual void f(); int f1 : 1; @};
1507 struct B : public A @{ int f2 : 1; @};
1508 @end smallexample
1509
1510 @noindent
1511 In this case, G++ will place @code{B::f2} into the same byte
1512 as@code{A::f1}; other compilers will not.  You can avoid this problem
1513 by explicitly padding @code{A} so that its size is a multiple of the
1514 byte size on your platform; that will cause G++ and other compilers to
1515 layout @code{B} identically.
1516
1517 @item
1518 Incorrect handling of tail-padding for virtual bases.  G++ does not use
1519 tail padding when laying out virtual bases.  For example:
1520
1521 @smallexample
1522 struct A @{ virtual void f(); char c1; @};
1523 struct B @{ B(); char c2; @};
1524 struct C : public A, public virtual B @{@};
1525 @end smallexample
1526
1527 @noindent
1528 In this case, G++ will not place @code{B} into the tail-padding for
1529 @code{A}; other compilers will.  You can avoid this problem by
1530 explicitly padding @code{A} so that its size is a multiple of its
1531 alignment (ignoring virtual base classes); that will cause G++ and other
1532 compilers to layout @code{C} identically.
1533
1534 @item
1535 Incorrect handling of bit-fields with declared widths greater than that
1536 of their underlying types, when the bit-fields appear in a union.  For
1537 example:
1538
1539 @smallexample
1540 union U @{ int i : 4096; @};
1541 @end smallexample
1542
1543 @noindent
1544 Assuming that an @code{int} does not have 4096 bits, G++ will make the
1545 union too small by the number of bits in an @code{int}.
1546
1547 @item
1548 Empty classes can be placed at incorrect offsets.  For example:
1549
1550 @smallexample
1551 struct A @{@};
1552
1553 struct B @{
1554   A a;
1555   virtual void f ();
1556 @};
1557
1558 struct C : public B, public A @{@};
1559 @end smallexample
1560
1561 @noindent
1562 G++ will place the @code{A} base class of @code{C} at a nonzero offset;
1563 it should be placed at offset zero.  G++ mistakenly believes that the
1564 @code{A} data member of @code{B} is already at offset zero.
1565
1566 @item
1567 Names of template functions whose types involve @code{typename} or
1568 template template parameters can be mangled incorrectly.
1569
1570 @smallexample
1571 template <typename Q>
1572 void f(typename Q::X) @{@}
1573
1574 template <template <typename> class Q>
1575 void f(typename Q<int>::X) @{@}
1576 @end smallexample
1577
1578 @noindent
1579 Instantiations of these templates may be mangled incorrectly.
1580
1581 @end itemize
1582
1583 @item -Wctor-dtor-privacy @r{(C++ only)}
1584 @opindex Wctor-dtor-privacy
1585 Warn when a class seems unusable because all the constructors or
1586 destructors in that class are private, and it has neither friends nor
1587 public static member functions.
1588
1589 @item -Wnon-virtual-dtor @r{(C++ only)}
1590 @opindex Wnon-virtual-dtor
1591 Warn when a class appears to be polymorphic, thereby requiring a virtual
1592 destructor, yet it declares a non-virtual one.
1593 This warning is enabled by @option{-Wall}.
1594
1595 @item -Wreorder @r{(C++ only)}
1596 @opindex Wreorder
1597 @cindex reordering, warning
1598 @cindex warning for reordering of member initializers
1599 Warn when the order of member initializers given in the code does not
1600 match the order in which they must be executed.  For instance:
1601
1602 @smallexample
1603 struct A @{
1604   int i;
1605   int j;
1606   A(): j (0), i (1) @{ @}
1607 @};
1608 @end smallexample
1609
1610 The compiler will rearrange the member initializers for @samp{i}
1611 and @samp{j} to match the declaration order of the members, emitting
1612 a warning to that effect.  This warning is enabled by @option{-Wall}.
1613 @end table
1614
1615 The following @option{-W@dots{}} options are not affected by @option{-Wall}.
1616
1617 @table @gcctabopt
1618 @item -Weffc++ @r{(C++ only)}
1619 @opindex Weffc++
1620 Warn about violations of the following style guidelines from Scott Meyers'
1621 @cite{Effective C++} book:
1622
1623 @itemize @bullet
1624 @item
1625 Item 11:  Define a copy constructor and an assignment operator for classes
1626 with dynamically allocated memory.
1627
1628 @item
1629 Item 12:  Prefer initialization to assignment in constructors.
1630
1631 @item
1632 Item 14:  Make destructors virtual in base classes.
1633
1634 @item
1635 Item 15:  Have @code{operator=} return a reference to @code{*this}.
1636
1637 @item
1638 Item 23:  Don't try to return a reference when you must return an object.
1639
1640 @end itemize
1641
1642 Also warn about violations of the following style guidelines from
1643 Scott Meyers' @cite{More Effective C++} book:
1644
1645 @itemize @bullet
1646 @item
1647 Item 6:  Distinguish between prefix and postfix forms of increment and
1648 decrement operators.
1649
1650 @item
1651 Item 7:  Never overload @code{&&}, @code{||}, or @code{,}.
1652
1653 @end itemize
1654
1655 When selecting this option, be aware that the standard library
1656 headers do not obey all of these guidelines; use @samp{grep -v}
1657 to filter out those warnings.
1658
1659 @item -Wno-deprecated @r{(C++ only)}
1660 @opindex Wno-deprecated
1661 Do not warn about usage of deprecated features.  @xref{Deprecated Features}.
1662
1663 @item -Wno-non-template-friend @r{(C++ only)}
1664 @opindex Wno-non-template-friend
1665 Disable warnings when non-templatized friend functions are declared
1666 within a template.  Since the advent of explicit template specification
1667 support in G++, if the name of the friend is an unqualified-id (i.e.,
1668 @samp{friend foo(int)}), the C++ language specification demands that the
1669 friend declare or define an ordinary, nontemplate function.  (Section
1670 14.5.3).  Before G++ implemented explicit specification, unqualified-ids
1671 could be interpreted as a particular specialization of a templatized
1672 function.  Because this non-conforming behavior is no longer the default
1673 behavior for G++, @option{-Wnon-template-friend} allows the compiler to
1674 check existing code for potential trouble spots and is on by default.
1675 This new compiler behavior can be turned off with
1676 @option{-Wno-non-template-friend} which keeps the conformant compiler code
1677 but disables the helpful warning.
1678
1679 @item -Wold-style-cast @r{(C++ only)}
1680 @opindex Wold-style-cast
1681 Warn if an old-style (C-style) cast to a non-void type is used within
1682 a C++ program.  The new-style casts (@samp{static_cast},
1683 @samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to
1684 unintended effects and much easier to search for.
1685
1686 @item -Woverloaded-virtual @r{(C++ only)}
1687 @opindex Woverloaded-virtual
1688 @cindex overloaded virtual fn, warning
1689 @cindex warning for overloaded virtual fn
1690 Warn when a function declaration hides virtual functions from a
1691 base class.  For example, in:
1692
1693 @smallexample
1694 struct A @{
1695   virtual void f();
1696 @};
1697
1698 struct B: public A @{
1699   void f(int);
1700 @};
1701 @end smallexample
1702
1703 the @code{A} class version of @code{f} is hidden in @code{B}, and code
1704 like:
1705
1706 @smallexample
1707 B* b;
1708 b->f();
1709 @end smallexample
1710
1711 will fail to compile.
1712
1713 @item -Wno-pmf-conversions @r{(C++ only)}
1714 @opindex Wno-pmf-conversions
1715 Disable the diagnostic for converting a bound pointer to member function
1716 to a plain pointer.
1717
1718 @item -Wsign-promo @r{(C++ only)}
1719 @opindex Wsign-promo
1720 Warn when overload resolution chooses a promotion from unsigned or
1721 enumerated type to a signed type, over a conversion to an unsigned type of
1722 the same size.  Previous versions of G++ would try to preserve
1723 unsignedness, but the standard mandates the current behavior.
1724
1725 @item -Wsynth @r{(C++ only)}
1726 @opindex Wsynth
1727 @cindex warning for synthesized methods
1728 @cindex synthesized methods, warning
1729 Warn when G++'s synthesis behavior does not match that of cfront.  For
1730 instance:
1731
1732 @smallexample
1733 struct A @{
1734   operator int ();
1735   A& operator = (int);
1736 @};
1737
1738 main ()
1739 @{
1740   A a,b;
1741   a = b;
1742 @}
1743 @end smallexample
1744
1745 In this example, G++ will synthesize a default @samp{A& operator =
1746 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1747 @end table
1748
1749 @node Objective-C Dialect Options
1750 @section Options Controlling Objective-C Dialect
1751
1752 @cindex compiler options, Objective-C
1753 @cindex Objective-C options, command line
1754 @cindex options, Objective-C
1755 (NOTE: This manual does not describe the Objective-C language itself.  See
1756 @w{@uref{http://gcc.gnu.org/readings.html}} for references.)
1757
1758 This section describes the command-line options that are only meaningful
1759 for Objective-C programs, but you can also use most of the GNU compiler
1760 options regardless of what language your program is in.  For example,
1761 you might compile a file @code{some_class.m} like this:
1762
1763 @smallexample
1764 gcc -g -fgnu-runtime -O -c some_class.m
1765 @end smallexample
1766
1767 @noindent
1768 In this example, @option{-fgnu-runtime} is an option meant only for
1769 Objective-C programs; you can use the other options with any language
1770 supported by GCC@.
1771
1772 Here is a list of options that are @emph{only} for compiling Objective-C
1773 programs:
1774
1775 @table @gcctabopt
1776 @item -fconstant-string-class=@var{class-name}
1777 @opindex fconstant-string-class
1778 Use @var{class-name} as the name of the class to instantiate for each
1779 literal string specified with the syntax @code{@@"@dots{}"}.  The default
1780 class name is @code{NXConstantString} if the GNU runtime is being used, and
1781 @code{NSConstantString} if the NeXT runtime is being used (see below).  The
1782 @option{-fconstant-cfstrings} option, if also present, will override the
1783 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
1784 to be laid out as constant CoreFoundation strings.
1785
1786 @item -fgnu-runtime
1787 @opindex fgnu-runtime
1788 Generate object code compatible with the standard GNU Objective-C
1789 runtime.  This is the default for most types of systems.
1790
1791 @item -fnext-runtime
1792 @opindex fnext-runtime
1793 Generate output compatible with the NeXT runtime.  This is the default
1794 for NeXT-based systems, including Darwin and Mac OS X@.  The macro
1795 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
1796 used.
1797
1798 @item -fno-nil-receivers
1799 @opindex fno-nil-receivers
1800 Assume that all Objective-C message dispatches (e.g.,
1801 @code{[receiver message:arg]}) in this translation unit ensure that the receiver
1802 is not @code{nil}.  This allows for more efficient entry points in the runtime to be
1803 used.  Currently, this option is only available in conjunction with
1804 the NeXT runtime on Mac OS X 10.3 and later.
1805
1806 @item -fobjc-exceptions
1807 @opindex fobjc-exceptions
1808 Enable syntactic support for structured exception handling in Objective-C,
1809 similar to what is offered by C++ and Java.  Currently, this option is only
1810 available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
1811
1812 @smallexample
1813   @@try @{
1814     @dots{}
1815        @@throw expr;
1816     @dots{}
1817   @}
1818   @@catch (AnObjCClass *exc) @{
1819     @dots{}
1820       @@throw expr;
1821     @dots{}
1822       @@throw;
1823     @dots{}
1824   @}
1825   @@catch (AnotherClass *exc) @{
1826     @dots{}
1827   @}
1828   @@catch (id allOthers) @{
1829     @dots{}
1830   @}
1831   @@finally @{
1832     @dots{}
1833       @@throw expr;
1834     @dots{}
1835   @}
1836 @end smallexample
1837
1838 The @code{@@throw} statement may appear anywhere in an Objective-C or
1839 Objective-C++ program; when used inside of a @code{@@catch} block, the
1840 @code{@@throw} may appear without an argument (as shown above), in which case
1841 the object caught by the @code{@@catch} will be rethrown.
1842
1843 Note that only (pointers to) Objective-C objects may be thrown and
1844 caught using this scheme.  When an object is thrown, it will be caught
1845 by the nearest @code{@@catch} clause capable of handling objects of that type,
1846 analogously to how @code{catch} blocks work in C++ and Java.  A
1847 @code{@@catch(id @dots{})} clause (as shown above) may also be provided to catch
1848 any and all Objective-C exceptions not caught by previous @code{@@catch}
1849 clauses (if any).
1850
1851 The @code{@@finally} clause, if present, will be executed upon exit from the
1852 immediately preceding @code{@@try @dots{} @@catch} section.  This will happen
1853 regardless of whether any exceptions are thrown, caught or rethrown
1854 inside the @code{@@try @dots{} @@catch} section, analogously to the behavior
1855 of the @code{finally} clause in Java.
1856
1857 There are several caveats to using the new exception mechanism:
1858
1859 @itemize @bullet
1860 @item
1861 Although currently designed to be binary compatible with @code{NS_HANDLER}-style
1862 idioms provided by the @code{NSException} class, the new
1863 exceptions can only be used on Mac OS X 10.3 (Panther) and later
1864 systems, due to additional functionality needed in the (NeXT) Objective-C
1865 runtime.
1866
1867 @item
1868 As mentioned above, the new exceptions do not support handling
1869 types other than Objective-C objects.   Furthermore, when used from
1870 Objective-C++, the Objective-C exception model does not interoperate with C++
1871 exceptions at this time.  This means you cannot @code{@@throw} an exception
1872 from Objective-C and @code{catch} it in C++, or vice versa
1873 (i.e., @code{throw @dots{} @@catch}).
1874 @end itemize
1875
1876 The @option{-fobjc-exceptions} switch also enables the use of synchronization
1877 blocks for thread-safe execution:
1878
1879 @smallexample
1880   @@synchronized (ObjCClass *guard) @{
1881     @dots{}
1882   @}
1883 @end smallexample
1884
1885 Upon entering the @code{@@synchronized} block, a thread of execution shall
1886 first check whether a lock has been placed on the corresponding @code{guard}
1887 object by another thread.  If it has, the current thread shall wait until
1888 the other thread relinquishes its lock.  Once @code{guard} becomes available,
1889 the current thread will place its own lock on it, execute the code contained in
1890 the @code{@@synchronized} block, and finally relinquish the lock (thereby
1891 making @code{guard} available to other threads).
1892
1893 Unlike Java, Objective-C does not allow for entire methods to be marked
1894 @code{@@synchronized}.  Note that throwing exceptions out of
1895 @code{@@synchronized} blocks is allowed, and will cause the guarding object
1896 to be unlocked properly.
1897
1898 @item -freplace-objc-classes
1899 @opindex freplace-objc-classes
1900 Emit a special marker instructing @command{ld(1)} not to statically link in
1901 the resulting object file, and allow @command{dyld(1)} to load it in at
1902 run time instead.  This is used in conjunction with the Fix-and-Continue
1903 debugging mode, where the object file in question may be recompiled and
1904 dynamically reloaded in the course of program execution, without the need
1905 to restart the program itself.  Currently, Fix-and-Continue functionality
1906 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
1907 and later.
1908
1909 @item -fzero-link
1910 @opindex fzero-link
1911 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
1912 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
1913 compile time) with static class references that get initialized at load time,
1914 which improves run-time performance.  Specifying the @option{-fzero-link} flag
1915 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
1916 to be retained.  This is useful in Zero-Link debugging mode, since it allows
1917 for individual class implementations to be modified during program execution.
1918
1919 @item -gen-decls
1920 @opindex gen-decls
1921 Dump interface declarations for all classes seen in the source file to a
1922 file named @file{@var{sourcename}.decl}.
1923
1924 @item -Wno-protocol
1925 @opindex Wno-protocol
1926 If a class is declared to implement a protocol, a warning is issued for
1927 every method in the protocol that is not implemented by the class.  The
1928 default behavior is to issue a warning for every method not explicitly
1929 implemented in the class, even if a method implementation is inherited
1930 from the superclass.  If you use the @code{-Wno-protocol} option, then
1931 methods inherited from the superclass are considered to be implemented,
1932 and no warning is issued for them.
1933
1934 @item -Wselector
1935 @opindex Wselector
1936 Warn if multiple methods of different types for the same selector are
1937 found during compilation.  The check is performed on the list of methods
1938 in the final stage of compilation.  Additionally, a check is performed
1939 for each selector appearing in a @code{@@selector(@dots{})}
1940 expression, and a corresponding method for that selector has been found
1941 during compilation.  Because these checks scan the method table only at
1942 the end of compilation, these warnings are not produced if the final
1943 stage of compilation is not reached, for example because an error is
1944 found during compilation, or because the @code{-fsyntax-only} option is
1945 being used.
1946
1947 @item -Wundeclared-selector
1948 @opindex Wundeclared-selector
1949 Warn if a @code{@@selector(@dots{})} expression referring to an
1950 undeclared selector is found.  A selector is considered undeclared if no
1951 method with that name has been declared before the
1952 @code{@@selector(@dots{})} expression, either explicitly in an
1953 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
1954 an @code{@@implementation} section.  This option always performs its
1955 checks as soon as a @code{@@selector(@dots{})} expression is found,
1956 while @code{-Wselector} only performs its checks in the final stage of
1957 compilation.  This also enforces the coding style convention
1958 that methods and selectors must be declared before being used.
1959
1960 @item -print-objc-runtime-info
1961 @opindex print-objc-runtime-info
1962 Generate C header describing the largest structure that is passed by
1963 value, if any.
1964
1965 @end table
1966
1967 @node Language Independent Options
1968 @section Options to Control Diagnostic Messages Formatting
1969 @cindex options to control diagnostics formatting
1970 @cindex diagnostic messages
1971 @cindex message formatting
1972
1973 Traditionally, diagnostic messages have been formatted irrespective of
1974 the output device's aspect (e.g.@: its width, @dots{}).  The options described
1975 below can be used to control the diagnostic messages formatting
1976 algorithm, e.g.@: how many characters per line, how often source location
1977 information should be reported.  Right now, only the C++ front end can
1978 honor these options.  However it is expected, in the near future, that
1979 the remaining front ends would be able to digest them correctly.
1980
1981 @table @gcctabopt
1982 @item -fmessage-length=@var{n}
1983 @opindex fmessage-length
1984 Try to format error messages so that they fit on lines of about @var{n}
1985 characters.  The default is 72 characters for @command{g++} and 0 for the rest of
1986 the front ends supported by GCC@.  If @var{n} is zero, then no
1987 line-wrapping will be done; each error message will appear on a single
1988 line.
1989
1990 @opindex fdiagnostics-show-location
1991 @item -fdiagnostics-show-location=once
1992 Only meaningful in line-wrapping mode.  Instructs the diagnostic messages
1993 reporter to emit @emph{once} source location information; that is, in
1994 case the message is too long to fit on a single physical line and has to
1995 be wrapped, the source location won't be emitted (as prefix) again,
1996 over and over, in subsequent continuation lines.  This is the default
1997 behavior.
1998
1999 @item -fdiagnostics-show-location=every-line
2000 Only meaningful in line-wrapping mode.  Instructs the diagnostic
2001 messages reporter to emit the same source location information (as
2002 prefix) for physical lines that result from the process of breaking
2003 a message which is too long to fit on a single line.
2004
2005 @end table
2006
2007 @node Warning Options
2008 @section Options to Request or Suppress Warnings
2009 @cindex options to control warnings
2010 @cindex warning messages
2011 @cindex messages, warning
2012 @cindex suppressing warnings
2013
2014 Warnings are diagnostic messages that report constructions which
2015 are not inherently erroneous but which are risky or suggest there
2016 may have been an error.
2017
2018 You can request many specific warnings with options beginning @samp{-W},
2019 for example @option{-Wimplicit} to request warnings on implicit
2020 declarations.  Each of these specific warning options also has a
2021 negative form beginning @samp{-Wno-} to turn off warnings;
2022 for example, @option{-Wno-implicit}.  This manual lists only one of the
2023 two forms, whichever is not the default.
2024
2025 The following options control the amount and kinds of warnings produced
2026 by GCC; for further, language-specific options also refer to
2027 @ref{C++ Dialect Options} and @ref{Objective-C Dialect Options}.
2028
2029 @table @gcctabopt
2030 @cindex syntax checking
2031 @item -fsyntax-only
2032 @opindex fsyntax-only
2033 Check the code for syntax errors, but don't do anything beyond that.
2034
2035 @item -pedantic
2036 @opindex pedantic
2037 Issue all the warnings demanded by strict ISO C and ISO C++;
2038 reject all programs that use forbidden extensions, and some other
2039 programs that do not follow ISO C and ISO C++.  For ISO C, follows the
2040 version of the ISO C standard specified by any @option{-std} option used.
2041
2042 Valid ISO C and ISO C++ programs should compile properly with or without
2043 this option (though a rare few will require @option{-ansi} or a
2044 @option{-std} option specifying the required version of ISO C)@.  However,
2045 without this option, certain GNU extensions and traditional C and C++
2046 features are supported as well.  With this option, they are rejected.
2047
2048 @option{-pedantic} does not cause warning messages for use of the
2049 alternate keywords whose names begin and end with @samp{__}.  Pedantic
2050 warnings are also disabled in the expression that follows
2051 @code{__extension__}.  However, only system header files should use
2052 these escape routes; application programs should avoid them.
2053 @xref{Alternate Keywords}.
2054
2055 Some users try to use @option{-pedantic} to check programs for strict ISO
2056 C conformance.  They soon find that it does not do quite what they want:
2057 it finds some non-ISO practices, but not all---only those for which
2058 ISO C @emph{requires} a diagnostic, and some others for which
2059 diagnostics have been added.
2060
2061 A feature to report any failure to conform to ISO C might be useful in
2062 some instances, but would require considerable additional work and would
2063 be quite different from @option{-pedantic}.  We don't have plans to
2064 support such a feature in the near future.
2065
2066 Where the standard specified with @option{-std} represents a GNU
2067 extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
2068 corresponding @dfn{base standard}, the version of ISO C on which the GNU
2069 extended dialect is based.  Warnings from @option{-pedantic} are given
2070 where they are required by the base standard.  (It would not make sense
2071 for such warnings to be given only for features not in the specified GNU
2072 C dialect, since by definition the GNU dialects of C include all
2073 features the compiler supports with the given option, and there would be
2074 nothing to warn about.)
2075
2076 @item -pedantic-errors
2077 @opindex pedantic-errors
2078 Like @option{-pedantic}, except that errors are produced rather than
2079 warnings.
2080
2081 @item -w
2082 @opindex w
2083 Inhibit all warning messages.
2084
2085 @item -Wno-import
2086 @opindex Wno-import
2087 Inhibit warning messages about the use of @samp{#import}.
2088
2089 @item -Wchar-subscripts
2090 @opindex Wchar-subscripts
2091 Warn if an array subscript has type @code{char}.  This is a common cause
2092 of error, as programmers often forget that this type is signed on some
2093 machines.
2094
2095 @item -Wcomment
2096 @opindex Wcomment
2097 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2098 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2099
2100 @item -Wfatal-errors
2101 @opindex Wfatal-errors
2102 This option causes the compiler to abort compilation on the first error
2103 occurred rather than trying to keep going and printing further error
2104 messages.
2105
2106 @item -Wformat
2107 @opindex Wformat
2108 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
2109 the arguments supplied have types appropriate to the format string
2110 specified, and that the conversions specified in the format string make
2111 sense.  This includes standard functions, and others specified by format
2112 attributes (@pxref{Function Attributes}), in the @code{printf},
2113 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
2114 not in the C standard) families.
2115
2116 The formats are checked against the format features supported by GNU
2117 libc version 2.2.  These include all ISO C90 and C99 features, as well
2118 as features from the Single Unix Specification and some BSD and GNU
2119 extensions.  Other library implementations may not support all these
2120 features; GCC does not support warning about features that go beyond a
2121 particular library's limitations.  However, if @option{-pedantic} is used
2122 with @option{-Wformat}, warnings will be given about format features not
2123 in the selected standard version (but not for @code{strfmon} formats,
2124 since those are not in any version of the C standard).  @xref{C Dialect
2125 Options,,Options Controlling C Dialect}.
2126
2127 Since @option{-Wformat} also checks for null format arguments for
2128 several functions, @option{-Wformat} also implies @option{-Wnonnull}.
2129
2130 @option{-Wformat} is included in @option{-Wall}.  For more control over some
2131 aspects of format checking, the options @option{-Wformat-y2k},
2132 @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
2133 @option{-Wformat-nonliteral}, @option{-Wformat-security}, and
2134 @option{-Wformat=2} are available, but are not included in @option{-Wall}.
2135
2136 @item -Wformat-y2k
2137 @opindex Wformat-y2k
2138 If @option{-Wformat} is specified, also warn about @code{strftime}
2139 formats which may yield only a two-digit year.
2140
2141 @item -Wno-format-extra-args
2142 @opindex Wno-format-extra-args
2143 If @option{-Wformat} is specified, do not warn about excess arguments to a
2144 @code{printf} or @code{scanf} format function.  The C standard specifies
2145 that such arguments are ignored.
2146
2147 Where the unused arguments lie between used arguments that are
2148 specified with @samp{$} operand number specifications, normally
2149 warnings are still given, since the implementation could not know what
2150 type to pass to @code{va_arg} to skip the unused arguments.  However,
2151 in the case of @code{scanf} formats, this option will suppress the
2152 warning if the unused arguments are all pointers, since the Single
2153 Unix Specification says that such unused arguments are allowed.
2154
2155 @item -Wno-format-zero-length
2156 @opindex Wno-format-zero-length
2157 If @option{-Wformat} is specified, do not warn about zero-length formats.
2158 The C standard specifies that zero-length formats are allowed.
2159
2160 @item -Wformat-nonliteral
2161 @opindex Wformat-nonliteral
2162 If @option{-Wformat} is specified, also warn if the format string is not a
2163 string literal and so cannot be checked, unless the format function
2164 takes its format arguments as a @code{va_list}.
2165
2166 @item -Wformat-security
2167 @opindex Wformat-security
2168 If @option{-Wformat} is specified, also warn about uses of format
2169 functions that represent possible security problems.  At present, this
2170 warns about calls to @code{printf} and @code{scanf} functions where the
2171 format string is not a string literal and there are no format arguments,
2172 as in @code{printf (foo);}.  This may be a security hole if the format
2173 string came from untrusted input and contains @samp{%n}.  (This is
2174 currently a subset of what @option{-Wformat-nonliteral} warns about, but
2175 in future warnings may be added to @option{-Wformat-security} that are not
2176 included in @option{-Wformat-nonliteral}.)
2177
2178 @item -Wformat=2
2179 @opindex Wformat=2
2180 Enable @option{-Wformat} plus format checks not included in
2181 @option{-Wformat}.  Currently equivalent to @samp{-Wformat
2182 -Wformat-nonliteral -Wformat-security -Wformat-y2k}.
2183
2184 @item -Wnonnull
2185 @opindex Wnonnull
2186 Warn about passing a null pointer for arguments marked as
2187 requiring a non-null value by the @code{nonnull} function attribute.
2188
2189 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}.  It
2190 can be disabled with the @option{-Wno-nonnull} option.
2191
2192 @item -Winit-self @r{(C, C++, and Objective-C only)}
2193 @opindex Winit-self
2194 Warn about uninitialized variables which are initialized with themselves.
2195 Note this option can only be used with the @option{-Wuninitialized} option,
2196 which in turn only works with @option{-O1} and above.
2197
2198 For example, GCC will warn about @code{i} being uninitialized in the
2199 following snippet only when @option{-Winit-self} has been specified:
2200 @smallexample
2201 @group
2202 int f()
2203 @{
2204   int i = i;
2205   return i;
2206 @}
2207 @end group
2208 @end smallexample
2209
2210 @item -Wimplicit-int
2211 @opindex Wimplicit-int
2212 Warn when a declaration does not specify a type.
2213
2214 @item -Wimplicit-function-declaration
2215 @itemx -Werror-implicit-function-declaration
2216 @opindex Wimplicit-function-declaration
2217 @opindex Werror-implicit-function-declaration
2218 Give a warning (or error) whenever a function is used before being
2219 declared.
2220
2221 @item -Wimplicit
2222 @opindex Wimplicit
2223 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
2224
2225 @item -Wmain
2226 @opindex Wmain
2227 Warn if the type of @samp{main} is suspicious.  @samp{main} should be a
2228 function with external linkage, returning int, taking either zero
2229 arguments, two, or three arguments of appropriate types.
2230
2231 @item -Wmissing-braces
2232 @opindex Wmissing-braces
2233 Warn if an aggregate or union initializer is not fully bracketed.  In
2234 the following example, the initializer for @samp{a} is not fully
2235 bracketed, but that for @samp{b} is fully bracketed.
2236
2237 @smallexample
2238 int a[2][2] = @{ 0, 1, 2, 3 @};
2239 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
2240 @end smallexample
2241
2242 @item -Wmissing-include-dirs @r{(C, C++, and Objective-C only)}
2243 @opindex Wmissing-include-dirs
2244 Warn if a user-supplied include directory does not exist.
2245
2246 @item -Wparentheses
2247 @opindex Wparentheses
2248 Warn if parentheses are omitted in certain contexts, such
2249 as when there is an assignment in a context where a truth value
2250 is expected, or when operators are nested whose precedence people
2251 often get confused about.
2252
2253 Also warn about constructions where there may be confusion to which
2254 @code{if} statement an @code{else} branch belongs.  Here is an example of
2255 such a case:
2256
2257 @smallexample
2258 @group
2259 @{
2260   if (a)
2261     if (b)
2262       foo ();
2263   else
2264     bar ();
2265 @}
2266 @end group
2267 @end smallexample
2268
2269 In C, every @code{else} branch belongs to the innermost possible @code{if}
2270 statement, which in this example is @code{if (b)}.  This is often not
2271 what the programmer expected, as illustrated in the above example by
2272 indentation the programmer chose.  When there is the potential for this
2273 confusion, GCC will issue a warning when this flag is specified.
2274 To eliminate the warning, add explicit braces around the innermost
2275 @code{if} statement so there is no way the @code{else} could belong to
2276 the enclosing @code{if}.  The resulting code would look like this:
2277
2278 @smallexample
2279 @group
2280 @{
2281   if (a)
2282     @{
2283       if (b)
2284         foo ();
2285       else
2286         bar ();
2287     @}
2288 @}
2289 @end group
2290 @end smallexample
2291
2292 @item -Wsequence-point
2293 @opindex Wsequence-point
2294 Warn about code that may have undefined semantics because of violations
2295 of sequence point rules in the C standard.
2296
2297 The C standard defines the order in which expressions in a C program are
2298 evaluated in terms of @dfn{sequence points}, which represent a partial
2299 ordering between the execution of parts of the program: those executed
2300 before the sequence point, and those executed after it.  These occur
2301 after the evaluation of a full expression (one which is not part of a
2302 larger expression), after the evaluation of the first operand of a
2303 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
2304 function is called (but after the evaluation of its arguments and the
2305 expression denoting the called function), and in certain other places.
2306 Other than as expressed by the sequence point rules, the order of
2307 evaluation of subexpressions of an expression is not specified.  All
2308 these rules describe only a partial order rather than a total order,
2309 since, for example, if two functions are called within one expression
2310 with no sequence point between them, the order in which the functions
2311 are called is not specified.  However, the standards committee have
2312 ruled that function calls do not overlap.
2313
2314 It is not specified when between sequence points modifications to the
2315 values of objects take effect.  Programs whose behavior depends on this
2316 have undefined behavior; the C standard specifies that ``Between the
2317 previous and next sequence point an object shall have its stored value
2318 modified at most once by the evaluation of an expression.  Furthermore,
2319 the prior value shall be read only to determine the value to be
2320 stored.''.  If a program breaks these rules, the results on any
2321 particular implementation are entirely unpredictable.
2322
2323 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
2324 = b[n++]} and @code{a[i++] = i;}.  Some more complicated cases are not
2325 diagnosed by this option, and it may give an occasional false positive
2326 result, but in general it has been found fairly effective at detecting
2327 this sort of problem in programs.
2328
2329 The present implementation of this option only works for C programs.  A
2330 future implementation may also work for C++ programs.
2331
2332 The C standard is worded confusingly, therefore there is some debate
2333 over the precise meaning of the sequence point rules in subtle cases.
2334 Links to discussions of the problem, including proposed formal
2335 definitions, may be found on our readings page, at
2336 @w{@uref{http://gcc.gnu.org/readings.html}}.
2337
2338 @item -Wreturn-type
2339 @opindex Wreturn-type
2340 Warn whenever a function is defined with a return-type that defaults to
2341 @code{int}.  Also warn about any @code{return} statement with no
2342 return-value in a function whose return-type is not @code{void}.
2343
2344 For C++, a function without return type always produces a diagnostic
2345 message, even when @option{-Wno-return-type} is specified.  The only
2346 exceptions are @samp{main} and functions defined in system headers.
2347
2348 @item -Wswitch
2349 @opindex Wswitch
2350 Warn whenever a @code{switch} statement has an index of enumerated type
2351 and lacks a @code{case} for one or more of the named codes of that
2352 enumeration.  (The presence of a @code{default} label prevents this
2353 warning.)  @code{case} labels outside the enumeration range also
2354 provoke warnings when this option is used.
2355
2356 @item -Wswitch-default
2357 @opindex Wswitch-switch
2358 Warn whenever a @code{switch} statement does not have a @code{default}
2359 case.
2360
2361 @item -Wswitch-enum
2362 @opindex Wswitch-enum
2363 Warn whenever a @code{switch} statement has an index of enumerated type
2364 and lacks a @code{case} for one or more of the named codes of that
2365 enumeration.  @code{case} labels outside the enumeration range also
2366 provoke warnings when this option is used.
2367
2368 @item -Wtrigraphs
2369 @opindex Wtrigraphs
2370 Warn if any trigraphs are encountered that might change the meaning of
2371 the program (trigraphs within comments are not warned about).
2372
2373 @item -Wunused-function
2374 @opindex Wunused-function
2375 Warn whenever a static function is declared but not defined or a
2376 non\-inline static function is unused.
2377
2378 @item -Wunused-label
2379 @opindex Wunused-label
2380 Warn whenever a label is declared but not used.
2381
2382 To suppress this warning use the @samp{unused} attribute
2383 (@pxref{Variable Attributes}).
2384
2385 @item -Wunused-parameter
2386 @opindex Wunused-parameter
2387 Warn whenever a function parameter is unused aside from its declaration.
2388
2389 To suppress this warning use the @samp{unused} attribute
2390 (@pxref{Variable Attributes}).
2391
2392 @item -Wunused-variable
2393 @opindex Wunused-variable
2394 Warn whenever a local variable or non-constant static variable is unused
2395 aside from its declaration
2396
2397 To suppress this warning use the @samp{unused} attribute
2398 (@pxref{Variable Attributes}).
2399
2400 @item -Wunused-value
2401 @opindex Wunused-value
2402 Warn whenever a statement computes a result that is explicitly not used.
2403
2404 To suppress this warning cast the expression to @samp{void}.
2405
2406 @item -Wunused
2407 @opindex Wunused
2408 All the above @option{-Wunused} options combined.
2409
2410 In order to get a warning about an unused function parameter, you must
2411 either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
2412 @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
2413
2414 @item -Wuninitialized
2415 @opindex Wuninitialized
2416 Warn if an automatic variable is used without first being initialized or
2417 if a variable may be clobbered by a @code{setjmp} call.
2418
2419 These warnings are possible only in optimizing compilation,
2420 because they require data flow information that is computed only
2421 when optimizing.  If you don't specify @option{-O}, you simply won't
2422 get these warnings.
2423
2424 If you want to warn about code which uses the uninitialized value of the
2425 variable in its own initializer, use the @option{-Winit-self} option.
2426
2427 These warnings occur only for variables that are candidates for
2428 register allocation.  Therefore, they do not occur for a variable that
2429 is declared @code{volatile}, or whose address is taken, or whose size
2430 is other than 1, 2, 4 or 8 bytes.  Also, they do not occur for
2431 structures, unions or arrays, even when they are in registers.
2432
2433 Note that there may be no warning about a variable that is used only
2434 to compute a value that itself is never used, because such
2435 computations may be deleted by data flow analysis before the warnings
2436 are printed.
2437
2438 These warnings are made optional because GCC is not smart
2439 enough to see all the reasons why the code might be correct
2440 despite appearing to have an error.  Here is one example of how
2441 this can happen:
2442
2443 @smallexample
2444 @group
2445 @{
2446   int x;
2447   switch (y)
2448     @{
2449     case 1: x = 1;
2450       break;
2451     case 2: x = 4;
2452       break;
2453     case 3: x = 5;
2454     @}
2455   foo (x);
2456 @}
2457 @end group
2458 @end smallexample
2459
2460 @noindent
2461 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
2462 always initialized, but GCC doesn't know this.  Here is
2463 another common case:
2464
2465 @smallexample
2466 @{
2467   int save_y;
2468   if (change_y) save_y = y, y = new_y;
2469   @dots{}
2470   if (change_y) y = save_y;
2471 @}
2472 @end smallexample
2473
2474 @noindent
2475 This has no bug because @code{save_y} is used only if it is set.
2476
2477 @cindex @code{longjmp} warnings
2478 This option also warns when a non-volatile automatic variable might be
2479 changed by a call to @code{longjmp}.  These warnings as well are possible
2480 only in optimizing compilation.
2481
2482 The compiler sees only the calls to @code{setjmp}.  It cannot know
2483 where @code{longjmp} will be called; in fact, a signal handler could
2484 call it at any point in the code.  As a result, you may get a warning
2485 even when there is in fact no problem because @code{longjmp} cannot
2486 in fact be called at the place which would cause a problem.
2487
2488 Some spurious warnings can be avoided if you declare all the functions
2489 you use that never return as @code{noreturn}.  @xref{Function
2490 Attributes}.
2491
2492 @item -Wunknown-pragmas
2493 @opindex Wunknown-pragmas
2494 @cindex warning for unknown pragmas
2495 @cindex unknown pragmas, warning
2496 @cindex pragmas, warning of unknown
2497 Warn when a #pragma directive is encountered which is not understood by
2498 GCC@.  If this command line option is used, warnings will even be issued
2499 for unknown pragmas in system header files.  This is not the case if
2500 the warnings were only enabled by the @option{-Wall} command line option.
2501
2502 @item -Wstrict-aliasing
2503 @opindex Wstrict-aliasing
2504 This option is only active when @option{-fstrict-aliasing} is active.
2505 It warns about code which might break the strict aliasing rules that the
2506 compiler is using for optimization. The warning does not catch all
2507 cases, but does attempt to catch the more common pitfalls. It is
2508 included in @option{-Wall}.
2509
2510 @item -Wstrict-aliasing=2
2511 @opindex Wstrict-aliasing=2
2512 This option is only active when @option{-fstrict-aliasing} is active.
2513 It warns about all code which might break the strict aliasing rules that the
2514 compiler is using for optimization.  This warning catches all cases, but
2515 it will also give a warning for some ambiguous cases that are safe.
2516
2517 @item -Wall
2518 @opindex Wall
2519 All of the above @samp{-W} options combined.  This enables all the
2520 warnings about constructions that some users consider questionable, and
2521 that are easy to avoid (or modify to prevent the warning), even in
2522 conjunction with macros.  This also enables some language-specific
2523 warnings described in @ref{C++ Dialect Options} and
2524 @ref{Objective-C Dialect Options}.
2525 @end table
2526
2527 The following @option{-W@dots{}} options are not implied by @option{-Wall}.
2528 Some of them warn about constructions that users generally do not
2529 consider questionable, but which occasionally you might wish to check
2530 for; others warn about constructions that are necessary or hard to avoid
2531 in some cases, and there is no simple way to modify the code to suppress
2532 the warning.
2533
2534 @table @gcctabopt
2535 @item -Wextra
2536 @opindex W
2537 @opindex Wextra
2538 (This option used to be called @option{-W}.  The older name is still
2539 supported, but the newer name is more descriptive.)  Print extra warning
2540 messages for these events:
2541
2542 @itemize @bullet
2543 @item
2544 A function can return either with or without a value.  (Falling
2545 off the end of the function body is considered returning without
2546 a value.)  For example, this function would evoke such a
2547 warning:
2548
2549 @smallexample
2550 @group
2551 foo (a)
2552 @{
2553   if (a > 0)
2554     return a;
2555 @}
2556 @end group
2557 @end smallexample
2558
2559 @item
2560 An expression-statement or the left-hand side of a comma expression
2561 contains no side effects.
2562 To suppress the warning, cast the unused expression to void.
2563 For example, an expression such as @samp{x[i,j]} will cause a warning,
2564 but @samp{x[(void)i,j]} will not.
2565
2566 @item
2567 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
2568
2569 @item
2570 A comparison like @samp{x<=y<=z} appears; this is equivalent to
2571 @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
2572 that of ordinary mathematical notation.
2573
2574 @item
2575 Storage-class specifiers like @code{static} are not the first things in
2576 a declaration.  According to the C Standard, this usage is obsolescent.
2577
2578 @item
2579 The return type of a function has a type qualifier such as @code{const}.
2580 Such a type qualifier has no effect, since the value returned by a
2581 function is not an lvalue.  (But don't warn about the GNU extension of
2582 @code{volatile void} return types.  That extension will be warned about
2583 if @option{-pedantic} is specified.)
2584
2585 @item
2586 If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
2587 arguments.
2588
2589 @item
2590 A comparison between signed and unsigned values could produce an
2591 incorrect result when the signed value is converted to unsigned.
2592 (But don't warn if @option{-Wno-sign-compare} is also specified.)
2593
2594 @item
2595 An aggregate has an initializer which does not initialize all members.
2596 For example, the following code would cause such a warning, because
2597 @code{x.h} would be implicitly initialized to zero:
2598
2599 @smallexample
2600 struct s @{ int f, g, h; @};
2601 struct s x = @{ 3, 4 @};
2602 @end smallexample
2603
2604 @item
2605 A function parameter is declared without a type specifier in K&R-style
2606 functions:
2607
2608 @smallexample
2609 void foo(bar) @{ @}
2610 @end smallexample
2611
2612 @item
2613 An empty body occurs in an @samp{if} or @samp{else} statement.
2614
2615 @item
2616 A pointer is compared against integer zero with @samp{<}, @samp{<=},
2617 @samp{>}, or @samp{>=}.
2618
2619 @item
2620 A variable might be changed by @samp{longjmp} or @samp{vfork}.
2621
2622 @item
2623 Any of several floating-point events that often indicate errors, such as
2624 overflow, underflow, loss of precision, etc.
2625
2626 @item @r{(C++ only)}
2627 An enumerator and a non-enumerator both appear in a conditional expression.
2628
2629 @item @r{(C++ only)}
2630 A non-static reference or non-static @samp{const} member appears in a
2631 class without constructors.
2632
2633 @item @r{(C++ only)}
2634 Ambiguous virtual bases.
2635
2636 @item @r{(C++ only)}
2637 Subscripting an array which has been declared @samp{register}.
2638
2639 @item @r{(C++ only)}
2640 Taking the address of a variable which has been declared @samp{register}.
2641
2642 @item @r{(C++ only)}
2643 A base class is not initialized in a derived class' copy constructor.
2644 @end itemize
2645
2646 @item -Wno-div-by-zero
2647 @opindex Wno-div-by-zero
2648 @opindex Wdiv-by-zero
2649 Do not warn about compile-time integer division by zero.  Floating point
2650 division by zero is not warned about, as it can be a legitimate way of
2651 obtaining infinities and NaNs.
2652
2653 @item -Wsystem-headers
2654 @opindex Wsystem-headers
2655 @cindex warnings from system headers
2656 @cindex system headers, warnings from
2657 Print warning messages for constructs found in system header files.
2658 Warnings from system headers are normally suppressed, on the assumption
2659 that they usually do not indicate real problems and would only make the
2660 compiler output harder to read.  Using this command line option tells
2661 GCC to emit warnings from system headers as if they occurred in user
2662 code.  However, note that using @option{-Wall} in conjunction with this
2663 option will @emph{not} warn about unknown pragmas in system
2664 headers---for that, @option{-Wunknown-pragmas} must also be used.
2665
2666 @item -Wfloat-equal
2667 @opindex Wfloat-equal
2668 Warn if floating point values are used in equality comparisons.
2669
2670 The idea behind this is that sometimes it is convenient (for the
2671 programmer) to consider floating-point values as approximations to
2672 infinitely precise real numbers.  If you are doing this, then you need
2673 to compute (by analyzing the code, or in some other way) the maximum or
2674 likely maximum error that the computation introduces, and allow for it
2675 when performing comparisons (and when producing output, but that's a
2676 different problem).  In particular, instead of testing for equality, you
2677 would check to see whether the two values have ranges that overlap; and
2678 this is done with the relational operators, so equality comparisons are
2679 probably mistaken.
2680
2681 @item -Wtraditional @r{(C only)}
2682 @opindex Wtraditional
2683 Warn about certain constructs that behave differently in traditional and
2684 ISO C@.  Also warn about ISO C constructs that have no traditional C
2685 equivalent, and/or problematic constructs which should be avoided.
2686
2687 @itemize @bullet
2688 @item
2689 Macro parameters that appear within string literals in the macro body.
2690 In traditional C macro replacement takes place within string literals,
2691 but does not in ISO C@.
2692
2693 @item
2694 In traditional C, some preprocessor directives did not exist.
2695 Traditional preprocessors would only consider a line to be a directive
2696 if the @samp{#} appeared in column 1 on the line.  Therefore
2697 @option{-Wtraditional} warns about directives that traditional C
2698 understands but would ignore because the @samp{#} does not appear as the
2699 first character on the line.  It also suggests you hide directives like
2700 @samp{#pragma} not understood by traditional C by indenting them.  Some
2701 traditional implementations would not recognize @samp{#elif}, so it
2702 suggests avoiding it altogether.
2703
2704 @item
2705 A function-like macro that appears without arguments.
2706
2707 @item
2708 The unary plus operator.
2709
2710 @item
2711 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2712 constant suffixes.  (Traditional C does support the @samp{L} suffix on integer
2713 constants.)  Note, these suffixes appear in macros defined in the system
2714 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
2715 Use of these macros in user code might normally lead to spurious
2716 warnings, however GCC's integrated preprocessor has enough context to
2717 avoid warning in these cases.
2718
2719 @item
2720 A function declared external in one block and then used after the end of
2721 the block.
2722
2723 @item
2724 A @code{switch} statement has an operand of type @code{long}.
2725
2726 @item
2727 A non-@code{static} function declaration follows a @code{static} one.
2728 This construct is not accepted by some traditional C compilers.
2729
2730 @item
2731 The ISO type of an integer constant has a different width or
2732 signedness from its traditional type.  This warning is only issued if
2733 the base of the constant is ten.  I.e.@: hexadecimal or octal values, which
2734 typically represent bit patterns, are not warned about.
2735
2736 @item
2737 Usage of ISO string concatenation is detected.
2738
2739 @item
2740 Initialization of automatic aggregates.
2741
2742 @item
2743 Identifier conflicts with labels.  Traditional C lacks a separate
2744 namespace for labels.
2745
2746 @item
2747 Initialization of unions.  If the initializer is zero, the warning is
2748 omitted.  This is done under the assumption that the zero initializer in
2749 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
2750 initializer warnings and relies on default initialization to zero in the
2751 traditional C case.
2752
2753 @item
2754 Conversions by prototypes between fixed/floating point values and vice
2755 versa.  The absence of these prototypes when compiling with traditional
2756 C would cause serious problems.  This is a subset of the possible
2757 conversion warnings, for the full set use @option{-Wconversion}.
2758
2759 @item
2760 Use of ISO C style function definitions.  This warning intentionally is
2761 @emph{not} issued for prototype declarations or variadic functions
2762 because these ISO C features will appear in your code when using
2763 libiberty's traditional C compatibility macros, @code{PARAMS} and
2764 @code{VPARAMS}.  This warning is also bypassed for nested functions
2765 because that feature is already a GCC extension and thus not relevant to
2766 traditional C compatibility.
2767 @end itemize
2768
2769 @item -Wdeclaration-after-statement @r{(C only)}
2770 @opindex Wdeclaration-after-statement
2771 Warn when a declaration is found after a statement in a block.  This
2772 construct, known from C++, was introduced with ISO C99 and is by default
2773 allowed in GCC@.  It is not supported by ISO C90 and was not supported by
2774 GCC versions before GCC 3.0.  @xref{Mixed Declarations}.
2775
2776 @item -Wundef
2777 @opindex Wundef
2778 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2779
2780 @item -Wendif-labels
2781 @opindex Wendif-labels
2782 Warn whenever an @samp{#else} or an @samp{#endif} are followed by text.
2783
2784 @item -Wshadow
2785 @opindex Wshadow
2786 Warn whenever a local variable shadows another local variable, parameter or
2787 global variable or whenever a built-in function is shadowed.
2788
2789 @item -Wlarger-than-@var{len}
2790 @opindex Wlarger-than
2791 Warn whenever an object of larger than @var{len} bytes is defined.
2792
2793 @item -Wpointer-arith
2794 @opindex Wpointer-arith
2795 Warn about anything that depends on the ``size of'' a function type or
2796 of @code{void}.  GNU C assigns these types a size of 1, for
2797 convenience in calculations with @code{void *} pointers and pointers
2798 to functions.
2799
2800 @item -Wbad-function-cast @r{(C only)}
2801 @opindex Wbad-function-cast
2802 Warn whenever a function call is cast to a non-matching type.
2803 For example, warn if @code{int malloc()} is cast to @code{anything *}.
2804
2805 @item -Wcast-qual
2806 @opindex Wcast-qual
2807 Warn whenever a pointer is cast so as to remove a type qualifier from
2808 the target type.  For example, warn if a @code{const char *} is cast
2809 to an ordinary @code{char *}.
2810
2811 @item -Wcast-align
2812 @opindex Wcast-align
2813 Warn whenever a pointer is cast such that the required alignment of the
2814 target is increased.  For example, warn if a @code{char *} is cast to
2815 an @code{int *} on machines where integers can only be accessed at
2816 two- or four-byte boundaries.
2817
2818 @item -Wwrite-strings
2819 @opindex Wwrite-strings
2820 When compiling C, give string constants the type @code{const
2821 char[@var{length}]} so that
2822 copying the address of one into a non-@code{const} @code{char *}
2823 pointer will get a warning; when compiling C++, warn about the
2824 deprecated conversion from string constants to @code{char *}.
2825 These warnings will help you find at
2826 compile time code that can try to write into a string constant, but
2827 only if you have been very careful about using @code{const} in
2828 declarations and prototypes.  Otherwise, it will just be a nuisance;
2829 this is why we did not make @option{-Wall} request these warnings.
2830
2831 @item -Wconversion
2832 @opindex Wconversion
2833 Warn if a prototype causes a type conversion that is different from what
2834 would happen to the same argument in the absence of a prototype.  This
2835 includes conversions of fixed point to floating and vice versa, and
2836 conversions changing the width or signedness of a fixed point argument
2837 except when the same as the default promotion.
2838
2839 Also, warn if a negative integer constant expression is implicitly
2840 converted to an unsigned type.  For example, warn about the assignment
2841 @code{x = -1} if @code{x} is unsigned.  But do not warn about explicit
2842 casts like @code{(unsigned) -1}.
2843
2844 @item -Wsign-compare
2845 @opindex Wsign-compare
2846 @cindex warning for comparison of signed and unsigned values
2847 @cindex comparison of signed and unsigned values, warning
2848 @cindex signed and unsigned values, comparison warning
2849 Warn when a comparison between signed and unsigned values could produce
2850 an incorrect result when the signed value is converted to unsigned.
2851 This warning is also enabled by @option{-Wextra}; to get the other warnings
2852 of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
2853
2854 @item -Waggregate-return
2855 @opindex Waggregate-return
2856 Warn if any functions that return structures or unions are defined or
2857 called.  (In languages where you can return an array, this also elicits
2858 a warning.)
2859
2860 @item -Wstrict-prototypes @r{(C only)}
2861 @opindex Wstrict-prototypes
2862 Warn if a function is declared or defined without specifying the
2863 argument types.  (An old-style function definition is permitted without
2864 a warning if preceded by a declaration which specifies the argument
2865 types.)
2866
2867 @item -Wold-style-definition @r{(C only)}
2868 @opindex Wold-style-definition
2869 Warn if an old-style function definition is used.  A warning is given
2870 even if there is a previous prototype.
2871
2872 @item -Wmissing-prototypes @r{(C only)}
2873 @opindex Wmissing-prototypes
2874 Warn if a global function is defined without a previous prototype
2875 declaration.  This warning is issued even if the definition itself
2876 provides a prototype.  The aim is to detect global functions that fail
2877 to be declared in header files.
2878
2879 @item -Wmissing-declarations @r{(C only)}
2880 @opindex Wmissing-declarations
2881 Warn if a global function is defined without a previous declaration.
2882 Do so even if the definition itself provides a prototype.
2883 Use this option to detect global functions that are not declared in
2884 header files.
2885
2886 @item -Wmissing-noreturn
2887 @opindex Wmissing-noreturn
2888 Warn about functions which might be candidates for attribute @code{noreturn}.
2889 Note these are only possible candidates, not absolute ones.  Care should
2890 be taken to manually verify functions actually do not ever return before
2891 adding the @code{noreturn} attribute, otherwise subtle code generation
2892 bugs could be introduced.  You will not get a warning for @code{main} in
2893 hosted C environments.
2894
2895 @item -Wmissing-format-attribute
2896 @opindex Wmissing-format-attribute
2897 @opindex Wformat
2898 If @option{-Wformat} is enabled, also warn about functions which might be
2899 candidates for @code{format} attributes.  Note these are only possible
2900 candidates, not absolute ones.  GCC will guess that @code{format}
2901 attributes might be appropriate for any function that calls a function
2902 like @code{vprintf} or @code{vscanf}, but this might not always be the
2903 case, and some functions for which @code{format} attributes are
2904 appropriate may not be detected.  This option has no effect unless
2905 @option{-Wformat} is enabled (possibly by @option{-Wall}).
2906
2907 @item -Wno-multichar
2908 @opindex Wno-multichar
2909 @opindex Wmultichar
2910 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
2911 Usually they indicate a typo in the user's code, as they have
2912 implementation-defined values, and should not be used in portable code.
2913
2914 @item -Wno-deprecated-declarations
2915 @opindex Wno-deprecated-declarations
2916 Do not warn about uses of functions, variables, and types marked as
2917 deprecated by using the @code{deprecated} attribute.
2918 (@pxref{Function Attributes}, @pxref{Variable Attributes},
2919 @pxref{Type Attributes}.)
2920
2921 @item -Wpacked
2922 @opindex Wpacked
2923 Warn if a structure is given the packed attribute, but the packed
2924 attribute has no effect on the layout or size of the structure.
2925 Such structures may be mis-aligned for little benefit.  For
2926 instance, in this code, the variable @code{f.x} in @code{struct bar}
2927 will be misaligned even though @code{struct bar} does not itself
2928 have the packed attribute:
2929
2930 @smallexample
2931 @group
2932 struct foo @{
2933   int x;
2934   char a, b, c, d;
2935 @} __attribute__((packed));
2936 struct bar @{
2937   char z;
2938   struct foo f;
2939 @};
2940 @end group
2941 @end smallexample
2942
2943 @item -Wpadded
2944 @opindex Wpadded
2945 Warn if padding is included in a structure, either to align an element
2946 of the structure or to align the whole structure.  Sometimes when this
2947 happens it is possible to rearrange the fields of the structure to
2948 reduce the padding and so make the structure smaller.
2949
2950 @item -Wredundant-decls
2951 @opindex Wredundant-decls
2952 Warn if anything is declared more than once in the same scope, even in
2953 cases where multiple declaration is valid and changes nothing.
2954
2955 @item -Wnested-externs @r{(C only)}
2956 @opindex Wnested-externs
2957 Warn if an @code{extern} declaration is encountered within a function.
2958
2959 @item -Wunreachable-code
2960 @opindex Wunreachable-code
2961 Warn if the compiler detects that code will never be executed.
2962
2963 This option is intended to warn when the compiler detects that at
2964 least a whole line of source code will never be executed, because
2965 some condition is never satisfied or because it is after a
2966 procedure that never returns.
2967
2968 It is possible for this option to produce a warning even though there
2969 are circumstances under which part of the affected line can be executed,
2970 so care should be taken when removing apparently-unreachable code.
2971
2972 For instance, when a function is inlined, a warning may mean that the
2973 line is unreachable in only one inlined copy of the function.
2974
2975 This option is not made part of @option{-Wall} because in a debugging
2976 version of a program there is often substantial code which checks
2977 correct functioning of the program and is, hopefully, unreachable
2978 because the program does work.  Another common use of unreachable
2979 code is to provide behavior which is selectable at compile-time.
2980
2981 @item -Winline
2982 @opindex Winline
2983 Warn if a function can not be inlined and it was declared as inline.
2984 Even with this option, the compiler will not warn about failures to
2985 inline functions declared in system headers.
2986
2987 The compiler uses a variety of heuristics to determine whether or not
2988 to inline a function.  For example, the compiler takes into account
2989 the size of the function being inlined and the the amount of inlining
2990 that has already been done in the current function.  Therefore,
2991 seemingly insignificant changes in the source program can cause the
2992 warnings produced by @option{-Winline} to appear or disappear.
2993
2994 @item -Wno-invalid-offsetof @r{(C++ only)}
2995 @opindex Wno-invalid-offsetof
2996 Suppress warnings from applying the @samp{offsetof} macro to a non-POD
2997 type.  According to the 1998 ISO C++ standard, applying @samp{offsetof}
2998 to a non-POD type is undefined.  In existing C++ implementations,
2999 however, @samp{offsetof} typically gives meaningful results even when
3000 applied to certain kinds of non-POD types. (Such as a simple
3001 @samp{struct} that fails to be a POD type only by virtue of having a
3002 constructor.)  This flag is for users who are aware that they are
3003 writing nonportable code and who have deliberately chosen to ignore the
3004 warning about it.
3005
3006 The restrictions on @samp{offsetof} may be relaxed in a future version
3007 of the C++ standard.
3008
3009 @item -Winvalid-pch
3010 @opindex Winvalid-pch
3011 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
3012 the search path but can't be used.
3013
3014 @item -Wlong-long
3015 @opindex Wlong-long
3016 @opindex Wno-long-long
3017 Warn if @samp{long long} type is used.  This is default.  To inhibit
3018 the warning messages, use @option{-Wno-long-long}.  Flags
3019 @option{-Wlong-long} and @option{-Wno-long-long} are taken into account
3020 only when @option{-pedantic} flag is used.
3021
3022 @item -Wvariadic-macros
3023 @opindex Wvariadic-macros
3024 @opindex Wno-variadic-macros
3025 Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
3026 alternate syntax when in pedantic ISO C99 mode.  This is default.
3027 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
3028
3029 @item -Wdisabled-optimization
3030 @opindex Wdisabled-optimization
3031 Warn if a requested optimization pass is disabled.  This warning does
3032 not generally indicate that there is anything wrong with your code; it
3033 merely indicates that GCC's optimizers were unable to handle the code
3034 effectively.  Often, the problem is that your code is too big or too
3035 complex; GCC will refuse to optimize programs when the optimization
3036 itself is likely to take inordinate amounts of time.
3037
3038 @item -Werror
3039 @opindex Werror
3040 Make all warnings into errors.
3041 @end table
3042
3043 @node Debugging Options
3044 @section Options for Debugging Your Program or GCC
3045 @cindex options, debugging
3046 @cindex debugging information options
3047
3048 GCC has various special options that are used for debugging
3049 either your program or GCC:
3050
3051 @table @gcctabopt
3052 @item -g
3053 @opindex g
3054 Produce debugging information in the operating system's native format
3055 (stabs, COFF, XCOFF, or DWARF)@.  GDB can work with this debugging
3056 information.
3057
3058 On most systems that use stabs format, @option{-g} enables use of extra
3059 debugging information that only GDB can use; this extra information
3060 makes debugging work better in GDB but will probably make other debuggers
3061 crash or
3062 refuse to read the program.  If you want to control for certain whether
3063 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
3064 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
3065
3066 Unlike most other C compilers, GCC allows you to use @option{-g} with
3067 @option{-O}.  The shortcuts taken by optimized code may occasionally
3068 produce surprising results: some variables you declared may not exist
3069 at all; flow of control may briefly move where you did not expect it;
3070 some statements may not be executed because they compute constant
3071 results or their values were already at hand; some statements may
3072 execute in different places because they were moved out of loops.
3073
3074 Nevertheless it proves possible to debug optimized output.  This makes
3075 it reasonable to use the optimizer for programs that might have bugs.
3076
3077 The following options are useful when GCC is generated with the
3078 capability for more than one debugging format.
3079
3080 @item -ggdb
3081 @opindex ggdb
3082 Produce debugging information for use by GDB@.  This means to use the
3083 most expressive format available (DWARF 2, stabs, or the native format
3084 if neither of those are supported), including GDB extensions if at all
3085 possible.
3086
3087 @item -gstabs
3088 @opindex gstabs
3089 Produce debugging information in stabs format (if that is supported),
3090 without GDB extensions.  This is the format used by DBX on most BSD
3091 systems.  On MIPS, Alpha and System V Release 4 systems this option
3092 produces stabs debugging output which is not understood by DBX or SDB@.
3093 On System V Release 4 systems this option requires the GNU assembler.
3094
3095 @item -feliminate-unused-debug-symbols
3096 @opindex feliminate-unused-debug-symbols
3097 Produce debugging information in stabs format (if that is supported),
3098 for only symbols that are actually used.
3099
3100 @item -gstabs+
3101 @opindex gstabs+
3102 Produce debugging information in stabs format (if that is supported),
3103 using GNU extensions understood only by the GNU debugger (GDB)@.  The
3104 use of these extensions is likely to make other debuggers crash or
3105 refuse to read the program.
3106
3107 @item -gcoff
3108 @opindex gcoff
3109 Produce debugging information in COFF format (if that is supported).
3110 This is the format used by SDB on most System V systems prior to
3111 System V Release 4.
3112
3113 @item -gxcoff
3114 @opindex gxcoff
3115 Produce debugging information in XCOFF format (if that is supported).
3116 This is the format used by the DBX debugger on IBM RS/6000 systems.
3117
3118 @item -gxcoff+
3119 @opindex gxcoff+
3120 Produce debugging information in XCOFF format (if that is supported),
3121 using GNU extensions understood only by the GNU debugger (GDB)@.  The
3122 use of these extensions is likely to make other debuggers crash or
3123 refuse to read the program, and may cause assemblers other than the GNU
3124 assembler (GAS) to fail with an error.
3125
3126 @item -gdwarf-2
3127 @opindex gdwarf-2
3128 Produce debugging information in DWARF version 2 format (if that is
3129 supported).  This is the format used by DBX on IRIX 6.
3130
3131 @item -gvms
3132 @opindex gvms
3133 Produce debugging information in VMS debug format (if that is
3134 supported).  This is the format used by DEBUG on VMS systems.
3135
3136 @item -g@var{level}
3137 @itemx -ggdb@var{level}
3138 @itemx -gstabs@var{level}
3139 @itemx -gcoff@var{level}
3140 @itemx -gxcoff@var{level}
3141 @itemx -gvms@var{level}
3142 Request debugging information and also use @var{level} to specify how
3143 much information.  The default level is 2.
3144
3145 Level 1 produces minimal information, enough for making backtraces in
3146 parts of the program that you don't plan to debug.  This includes
3147 descriptions of functions and external variables, but no information
3148 about local variables and no line numbers.
3149
3150 Level 3 includes extra information, such as all the macro definitions
3151 present in the program.  Some debuggers support macro expansion when
3152 you use @option{-g3}.
3153
3154 Note that in order to avoid confusion between DWARF1 debug level 2,
3155 and DWARF2 @option{-gdwarf-2} does not accept a concatenated debug
3156 level.  Instead use an additional @option{-g@var{level}} option to
3157 change the debug level for DWARF2.
3158
3159 @item -feliminate-dwarf2-dups
3160 @opindex feliminate-dwarf2-dups
3161 Compress DWARF2 debugging information by eliminating duplicated
3162 information about each symbol.  This option only makes sense when
3163 generating DWARF2 debugging information with @option{-gdwarf-2}.
3164
3165 @cindex @command{prof}
3166 @item -p
3167 @opindex p
3168 Generate extra code to write profile information suitable for the
3169 analysis program @command{prof}.  You must use this option when compiling
3170 the source files you want data about, and you must also use it when
3171 linking.
3172
3173 @cindex @command{gprof}
3174 @item -pg
3175 @opindex pg
3176 Generate extra code to write profile information suitable for the
3177 analysis program @command{gprof}.  You must use this option when compiling
3178 the source files you want data about, and you must also use it when
3179 linking.
3180
3181 @item -Q
3182 @opindex Q
3183 Makes the compiler print out each function name as it is compiled, and
3184 print some statistics about each pass when it finishes.
3185
3186 @item -ftime-report
3187 @opindex ftime-report
3188 Makes the compiler print some statistics about the time consumed by each
3189 pass when it finishes.
3190
3191 @item -fmem-report
3192 @opindex fmem-report
3193 Makes the compiler print some statistics about permanent memory
3194 allocation when it finishes.
3195
3196 @item -fprofile-arcs
3197 @opindex fprofile-arcs
3198 Add code so that program flow @dfn{arcs} are instrumented.  During
3199 execution the program records how many times each branch and call is
3200 executed and how many times it is taken or returns.  When the compiled
3201 program exits it saves this data to a file called
3202 @file{@var{auxname}.gcda} for each source file. The data may be used for
3203 profile-directed optimizations (@option{-fbranch-probabilities}), or for
3204 test coverage analysis (@option{-ftest-coverage}). Each object file's
3205 @var{auxname} is generated from the name of the output file, if
3206 explicitly specified and it is not the final executable, otherwise it is
3207 the basename of the source file. In both cases any suffix is removed
3208 (e.g.  @file{foo.gcda} for input file @file{dir/foo.c}, or
3209 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
3210
3211 @itemize
3212
3213 @item
3214 Compile the source files with @option{-fprofile-arcs} plus optimization
3215 and code generation options. For test coverage analysis, use the
3216 additional @option{-ftest-coverage} option. You do not need to profile
3217 every source file in a program.
3218
3219 @item
3220 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
3221 (the latter implies the former).
3222
3223 @item
3224 Run the program on a representative workload to generate the arc profile
3225 information. This may be repeated any number of times. You can run
3226 concurrent instances of your program, and provided that the file system
3227 supports locking, the data files will be correctly updated. Also
3228 @code{fork} calls are detected and correctly handled (double counting
3229 will not happen).
3230
3231 @item
3232 For profile-directed optimizations, compile the source files again with
3233 the same optimization and code generation options plus
3234 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3235 Control Optimization}).
3236
3237 @item
3238 For test coverage analysis, use @command{gcov} to produce human readable
3239 information from the @file{.gcno} and @file{.gcda} files. Refer to the
3240 @command{gcov} documentation for further information.
3241
3242 @end itemize
3243
3244 With @option{-fprofile-arcs}, for each function of your program GCC
3245 creates a program flow graph, then finds a spanning tree for the graph.
3246 Only arcs that are not on the spanning tree have to be instrumented: the
3247 compiler adds code to count the number of times that these arcs are
3248 executed.  When an arc is the only exit or only entrance to a block, the
3249 instrumentation code can be added to the block; otherwise, a new basic
3250 block must be created to hold the instrumentation code.
3251
3252 @item -ftree-based-profiling
3253 @opindex ftree-based-profiling
3254 This option is used in addition to @option{-fprofile-arcs} or
3255 @option{-fbranch-probabilities} to control whether those optimizations
3256 are performed on a tree-based or rtl-based internal representation.
3257 If you use this option when compiling with @option{-fprofile-arcs},
3258 you must also use it when compiling later with @option{-fbranch-probabilities}.
3259 Currently the tree-based optimization is in an early stage of
3260 development, and this option is recommended only for those people
3261 working on improving it.
3262
3263 @need 2000
3264 @item -ftest-coverage
3265 @opindex ftest-coverage
3266 Produce a notes file that the @command{gcov} code-coverage utility
3267 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
3268 show program coverage. Each source file's note file is called
3269 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
3270 above for a description of @var{auxname} and instructions on how to
3271 generate test coverage data. Coverage data will match the source files
3272 more closely, if you do not optimize.
3273
3274 @item -d@var{letters}
3275 @opindex d
3276 Says to make debugging dumps during compilation at times specified by
3277 @var{letters}.  This is used for debugging the compiler.  The file names
3278 for most of the dumps are made by appending a pass number and a word to
3279 the @var{dumpname}. @var{dumpname} is generated from the name of the
3280 output file, if explicitly specified and it is not an executable,
3281 otherwise it is the basename of the source file. In both cases any
3282 suffix is removed (e.g.  @file{foo.01.rtl} or @file{foo.02.sibling}).
3283 Here are the possible letters for use in @var{letters}, and their
3284 meanings:
3285
3286 @table @samp
3287 @item A
3288 @opindex dA
3289 Annotate the assembler output with miscellaneous debugging information.
3290 @item b
3291 @opindex db
3292 Dump after computing branch probabilities, to @file{@var{file}.12.bp}.
3293 @item B
3294 @opindex dB
3295 Dump after block reordering, to @file{@var{file}.32.bbro}.
3296 @item c
3297 @opindex dc
3298 Dump after instruction combination, to the file @file{@var{file}.20.combine}.
3299 @item C
3300 @opindex dC
3301 Dump after the first if conversion, to the file @file{@var{file}.14.ce1}.
3302 Also dump after the second if conversion, to the file @file{@var{file}.21.ce2}.
3303 @item d
3304 @opindex dd
3305 Dump after branch target load optimization, to to @file{@var{file}.33.btl}.
3306 Also dump after delayed branch scheduling, to @file{@var{file}.37.dbr}.
3307 @item D
3308 @opindex dD
3309 Dump all macro definitions, at the end of preprocessing, in addition to
3310 normal output.
3311 @item E
3312 @opindex dE
3313 Dump after the third if conversion, to @file{@var{file}.31.ce3}.
3314 @item f
3315 @opindex df
3316 Dump after control and data flow analysis, to @file{@var{file}.11.cfg}.
3317 Also dump after life analysis, to @file{@var{file}.19.life}.
3318 @item F
3319 @opindex dF
3320 Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.07.addressof}.
3321 @item g
3322 @opindex dg
3323 Dump after global register allocation, to @file{@var{file}.26.greg}.
3324 @item G
3325 @opindex dG
3326 Dump after GCSE, to @file{@var{file}.08.gcse}.
3327 Also dump after jump bypassing and control flow optimizations, to
3328 @file{@var{file}.10.bypass}.
3329 @item h
3330 @opindex dh
3331 Dump after finalization of EH handling code, to @file{@var{file}.03.eh}.
3332 @item i
3333 @opindex di
3334 Dump after sibling call optimizations, to @file{@var{file}.02.sibling}.
3335 @item j
3336 @opindex dj
3337 Dump after the first jump optimization, to @file{@var{file}.04.jump}.
3338 @item k
3339 @opindex dk
3340 Dump after conversion from registers to stack, to @file{@var{file}.35.stack}.
3341 @item l
3342 @opindex dl
3343 Dump after local register allocation, to @file{@var{file}.25.lreg}.
3344 @item L
3345 @opindex dL
3346 Dump after loop optimization passes, to @file{@var{file}.09.loop} and
3347 @file{@var{file}.16.loop2}.
3348 @item m
3349 @opindex dm
3350 Dump after modulo scheduling, to @file{@var{file}.23.sms}.
3351 @item M
3352 @opindex dM
3353 Dump after performing the machine dependent reorganization pass, to
3354 @file{@var{file}.36.mach}.
3355 @item n
3356 @opindex dn
3357 Dump after register renumbering, to @file{@var{file}.30.rnreg}.
3358 @item N
3359 @opindex dN
3360 Dump after the register move pass, to @file{@var{file}.22.regmove}.
3361 @item o
3362 @opindex do
3363 Dump after post-reload optimizations, to @file{@var{file}.27.postreload}.
3364 @item r
3365 @opindex dr
3366 Dump after RTL generation, to @file{@var{file}.01.rtl}.
3367 @item R
3368 @opindex dR
3369 Dump after the second scheduling pass, to @file{@var{file}.34.sched2}.
3370 @item s
3371 @opindex ds
3372 Dump after CSE (including the jump optimization that sometimes follows
3373 CSE), to @file{@var{file}.06.cse}.
3374 @item S
3375 @opindex dS
3376 Dump after the first scheduling pass, to @file{@var{file}.24.sched}.
3377 @item t
3378 @opindex dt
3379 Dump after the second CSE pass (including the jump optimization that
3380 sometimes follows CSE), to @file{@var{file}.18.cse2}.
3381 @item T
3382 @opindex dT
3383 Dump after running tracer, to @file{@var{file}.15.tracer}.
3384 @item u
3385 @opindex du
3386 Dump after null pointer elimination pass to @file{@var{file}.05.null}.
3387 @item U
3388 @opindex dU
3389 Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
3390 @item V
3391 @opindex dV
3392 Dump after the value profile transformations, to @file{@var{file}.13.vpt}.
3393 Also dump after variable tracking, to @file{@var{file}.35.vartrack}.
3394 @item w
3395 @opindex dw
3396 Dump after the second flow pass, to @file{@var{file}.28.flow2}.
3397 @item z
3398 @opindex dz
3399 Dump after the peephole pass, to @file{@var{file}.29.peephole2}.
3400 @item Z
3401 @opindex dZ
3402 Dump after constructing the web, to @file{@var{file}.17.web}.
3403 @item a
3404 @opindex da
3405 Produce all the dumps listed above.
3406 @item H
3407 @opindex dH
3408 Produce a core dump whenever an error occurs.
3409 @item m
3410 @opindex dm
3411 Print statistics on memory usage, at the end of the run, to
3412 standard error.
3413 @item p
3414 @opindex dp
3415 Annotate the assembler output with a comment indicating which
3416 pattern and alternative was used.  The length of each instruction is
3417 also printed.
3418 @item P
3419 @opindex dP
3420 Dump the RTL in the assembler output as a comment before each instruction.
3421 Also turns on @option{-dp} annotation.
3422 @item v
3423 @opindex dv
3424 For each of the other indicated dump files (except for
3425 @file{@var{file}.01.rtl}), dump a representation of the control flow graph
3426 suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
3427 @item x
3428 @opindex dx
3429 Just generate RTL for a function instead of compiling it.  Usually used
3430 with @samp{r}.
3431 @item y
3432 @opindex dy
3433 Dump debugging information during parsing, to standard error.
3434 @end table
3435
3436 @item -fdump-unnumbered
3437 @opindex fdump-unnumbered
3438 When doing debugging dumps (see @option{-d} option above), suppress instruction
3439 numbers and line number note output.  This makes it more feasible to
3440 use diff on debugging dumps for compiler invocations with different
3441 options, in particular with and without @option{-g}.
3442
3443 @item -fdump-translation-unit @r{(C and C++ only)}
3444 @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
3445 @opindex fdump-translation-unit
3446 Dump a representation of the tree structure for the entire translation
3447 unit to a file.  The file name is made by appending @file{.tu} to the
3448 source file name.  If the @samp{-@var{options}} form is used, @var{options}
3449 controls the details of the dump as described for the
3450 @option{-fdump-tree} options.
3451
3452 @item -fdump-class-hierarchy @r{(C++ only)}
3453 @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
3454 @opindex fdump-class-hierarchy
3455 Dump a representation of each class's hierarchy and virtual function
3456 table layout to a file.  The file name is made by appending @file{.class}
3457 to the source file name.  If the @samp{-@var{options}} form is used,
3458 @var{options} controls the details of the dump as described for the
3459 @option{-fdump-tree} options.
3460
3461 @item -fdump-tree-@var{switch} @r{(C and C++ only)}
3462 @itemx -fdump-tree-@var{switch}-@var{options} @r{(C and C++ only)}
3463 @opindex fdump-tree
3464 Control the dumping at various stages of processing the intermediate
3465 language tree to a file.  The file name is generated by appending a switch
3466 specific suffix to the source file name.  If the @samp{-@var{options}}
3467 form is used, @var{options} is a list of @samp{-} separated options that
3468 control the details of the dump. Not all options are applicable to all
3469 dumps, those which are not meaningful will be ignored. The following
3470 options are available
3471
3472 @table @samp
3473 @item address
3474 Print the address of each node.  Usually this is not meaningful as it
3475 changes according to the environment and source file. Its primary use
3476 is for tying up a dump file with a debug environment.
3477 @item slim
3478 Inhibit dumping of members of a scope or body of a function merely
3479 because that scope has been reached.  Only dump such items when they
3480 are directly reachable by some other path.  When dumping pretty-printed
3481 trees, this option inhibits dumping the bodies of control structures.
3482 @item raw
3483 Print a raw representation of the tree.  By default, trees are
3484 pretty-printed into a C-like representation.
3485 @item details
3486 Enable more detailed dumps (not honored by every dump option).
3487 @item stats
3488 Enable dumping various statistics about the pass (not honored by every dump
3489 option).
3490 @item blocks
3491 Enable showing basic block boundaries (disabled in raw dumps).
3492 @item vops
3493 Enable showing virtual operands for every statement.
3494 @item lineno
3495 Enable showing line numbers for statements.
3496 @item uid
3497 Enable showing the unique ID (@code{DECL_UID}) for each variable.
3498 @item all
3499 Turn on all options, except @option{raw}, @option{slim} and @option{lineno}.
3500 @end table
3501
3502 The following tree dumps are possible:
3503 @table @samp
3504
3505 @item original
3506 Dump before any tree based optimization, to @file{@var{file}.original}.
3507
3508 @item optimized
3509 Dump after all tree based optimization, to @file{@var{file}.optimized}.
3510
3511 @item inlined
3512 Dump after function inlining, to @file{@var{file}.inlined}.
3513
3514 @item gimple
3515 @opindex fdump-tree-gimple
3516 Dump each function before and after the gimplification pass to a file.  The
3517 file name is made by appending @file{.gimple} to the source file name.
3518
3519 @item cfg
3520 @opindex fdump-tree-cfg
3521 Dump the control flow graph of each function to a file.  The file name is
3522 made by appending @file{.cfg} to the source file name.
3523
3524 @item vcg
3525 @opindex fdump-tree-vcg
3526 Dump the control flow graph of each function to a file in VCG format.  The
3527 file name is made by appending @file{.vcg} to the source file name.  Note
3528 that if the file contains more than one function, the generated file cannot
3529 be used directly by VCG.  You will need to cut and paste each function's
3530 graph into its own separate file first.
3531
3532 @item ch
3533 @opindex fdump-tree-ch
3534 Dump each function after copying loop headers.  The file name is made by
3535 appending @file{.ch} to the source file name.
3536
3537 @item ssa
3538 @opindex fdump-tree-ssa
3539 Dump SSA related information to a file.  The file name is made by appending
3540 @file{.ssa} to the source file name.
3541
3542 @item alias
3543 @opindex fdump-tree-alias
3544 Dump aliasing information for each function.  The file name is made by
3545 appending @file{.alias} to the source file name.
3546
3547 @item ccp
3548 @opindex fdump-tree-ccp
3549 Dump each function after CCP.  The file name is made by appending
3550 @file{.ccp} to the source file name.
3551
3552 @item pre
3553 @opindex fdump-tree-pre
3554 Dump trees after partial redundancy elimination.  The file name is made
3555 by appending @file{.pre} to the source file name.
3556
3557 @item fre
3558 @opindex fdump-tree-fre
3559 Dump trees after full redundancy elimination.  The file name is made
3560 by appending @file{.fre} to the source file name.
3561
3562 @item dce
3563 @opindex fdump-tree-dce
3564 Dump each function after dead code elimination.  The file name is made by
3565 appending @file{.dce} to the source file name.
3566
3567 @item mudflap
3568 @opindex fdump-tree-mudflap
3569 Dump each function after adding mudflap instrumentation.  The file name is
3570 made by appending @file{.mudflap} to the source file name.
3571
3572 @item sra
3573 @opindex fdump-tree-sra
3574 Dump each function after performing scalar replacement of aggregates.  The
3575 file name is made by appending @file{.sra} to the source file name.
3576
3577 @item dom
3578 @opindex fdump-tree-dom
3579 Dump each function after applying dominator tree optimizations.  The file
3580 name is made by appending @file{.dom} to the source file name.
3581
3582 @item dse
3583 @opindex fdump-tree-dse
3584 Dump each function after applying dead store elimination.  The file
3585 name is made by appending @file{.dse} to the source file name.
3586
3587 @item phiopt
3588 @opindex fdump-tree-phiopt
3589 Dump each function after optimizing PHI nodes into straightline code.  The file
3590 name is made by appending @file{.phiopt} to the source file name.
3591
3592 @item forwprop
3593 @opindex fdump-tree-forwprop
3594 Dump each function after forward propagating single use variables.  The file
3595 name is made by appending @file{.forwprop} to the source file name.
3596
3597 @item copyrename
3598 @opindex fdump-tree-copyrename
3599 Dump each function after applying the copy rename optimization.  The file
3600 name is made by appending @file{.copyrename} to the source file name.
3601
3602 @item nrv
3603 @opindex fdump-tree-nrv
3604 Dump each function after applying the named return value optimization on
3605 generic trees.  The file name is made by appending @file{.nrv} to the source
3606 file name.
3607
3608 @item all
3609 @opindex fdump-tree-all
3610 Enable all the available tree dumps with the flags provided in this option.
3611 @end table
3612
3613 @item -frandom-seed=@var{string}
3614 @opindex frandom-string
3615 This option provides a seed that GCC uses when it would otherwise use
3616 random numbers.  It is used to generate certain symbol names
3617 that have to be different in every compiled file. It is also used to
3618 place unique stamps in coverage data files and the object files that
3619 produce them. You can use the @option{-frandom-seed} option to produce
3620 reproducibly identical object files.
3621
3622 The @var{string} should be different for every file you compile.
3623
3624 @item -fsched-verbose=@var{n}
3625 @opindex fsched-verbose
3626 On targets that use instruction scheduling, this option controls the
3627 amount of debugging output the scheduler prints.  This information is
3628 written to standard error, unless @option{-dS} or @option{-dR} is
3629 specified, in which case it is output to the usual dump
3630 listing file, @file{.sched} or @file{.sched2} respectively.  However
3631 for @var{n} greater than nine, the output is always printed to standard
3632 error.
3633
3634 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
3635 same information as @option{-dRS}.  For @var{n} greater than one, it