OSDN Git Service

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