OSDN Git Service

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