OSDN Git Service

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