OSDN Git Service

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