OSDN Git Service

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