OSDN Git Service

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