OSDN Git Service

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