OSDN Git Service

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