OSDN Git Service

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