1 @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2 @c 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
8 Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
9 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.2 or
13 any later version published by the Free Software Foundation; with the
14 Invariant Sections being ``GNU General Public License'' and ``Funding
15 Free Software'', the Front-Cover texts being (a) (see below), and with
16 the Back-Cover Texts being (b) (see below). A copy of the license is
17 included in the gfdl(7) man page.
19 (a) The FSF's Front-Cover Text is:
23 (b) The FSF's Back-Cover Text is:
25 You have freedom to copy and modify this GNU Manual, like GNU
26 software. Copies published by the Free Software Foundation raise
27 funds for GNU development.
29 @c Set file name and title for the man page.
31 @settitle GNU project C and C++ compiler
33 gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}]
34 [@option{-g}] [@option{-pg}] [@option{-O}@var{level}]
35 [@option{-W}@var{warn}@dots{}] [@option{-pedantic}]
36 [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}]
37 [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}]
38 [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}]
39 [@option{-o} @var{outfile}] @var{infile}@dots{}
41 Only the most useful options are listed here; see below for the
42 remainder. @samp{g++} accepts mostly the same options as @samp{gcc}.
45 gpl(7), gfdl(7), fsf-funding(7),
46 cpp(1), gcov(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1)
47 and the Info entries for @file{gcc}, @file{cpp}, @file{as},
48 @file{ld}, @file{binutils} and @file{gdb}.
51 For instructions on reporting bugs, see
52 @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug}
53 script to report bugs is recommended.
56 See the Info entry for @command{gcc}, or
57 @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}},
58 for contributors to GCC@.
63 @chapter GCC Command Options
64 @cindex GCC command options
65 @cindex command options
66 @cindex options, GCC command
68 @c man begin DESCRIPTION
69 When you invoke GCC, it normally does preprocessing, compilation,
70 assembly and linking. The ``overall options'' allow you to stop this
71 process at an intermediate stage. For example, the @option{-c} option
72 says not to run the linker. Then the output consists of object files
73 output by the assembler.
75 Other options are passed on to one stage of processing. Some options
76 control the preprocessor and others the compiler itself. Yet other
77 options control the assembler and linker; most of these are not
78 documented here, since you rarely need to use any of them.
80 @cindex C compilation options
81 Most of the command line options that you can use with GCC are useful
82 for C programs; when an option is only useful with another language
83 (usually C++), the explanation says so explicitly. If the description
84 for a particular option does not mention a source language, you can use
85 that option with all supported languages.
87 @cindex C++ compilation options
88 @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
89 options for compiling C++ programs.
91 @cindex grouping options
92 @cindex options, grouping
93 The @command{gcc} program accepts options and file names as operands. Many
94 options have multi-letter names; therefore multiple single-letter options
95 may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d
98 @cindex order of options
99 @cindex options, order
100 You can mix options and other arguments. For the most part, the order
101 you use doesn't matter. Order does matter when you use several options
102 of the same kind; for example, if you specify @option{-L} more than once,
103 the directories are searched in the order specified.
105 Many options have long names starting with @samp{-f} or with
106 @samp{-W}---for example, @option{-fforce-mem},
107 @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of
108 these have both positive and negative forms; the negative form of
109 @option{-ffoo} would be @option{-fno-foo}. This manual documents
110 only one of these two forms, whichever one is not the default.
114 @xref{Option Index}, for an index to GCC's options.
117 * Option Summary:: Brief list of all options, without explanations.
118 * Overall Options:: Controlling the kind of output:
119 an executable, object files, assembler files,
120 or preprocessed source.
121 * Invoking G++:: Compiling C++ programs.
122 * C Dialect Options:: Controlling the variant of C language compiled.
123 * C++ Dialect Options:: Variations on C++.
124 * Objective-C Dialect Options:: Variations on Objective-C.
125 * Language Independent Options:: Controlling how diagnostics should be
127 * Warning Options:: How picky should the compiler be?
128 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
129 * Optimize Options:: How much optimization?
130 * Preprocessor Options:: Controlling header files and macro definitions.
131 Also, getting dependency information for Make.
132 * Assembler Options:: Passing options to the assembler.
133 * Link Options:: Specifying libraries and so on.
134 * Directory Options:: Where to find header files and libraries.
135 Where to find the compiler executable files.
136 * Spec Files:: How to pass switches to sub-processes.
137 * Target Options:: Running a cross-compiler, or an old version of GCC.
138 * Submodel Options:: Specifying minor hardware or convention variations,
139 such as 68010 vs 68020.
140 * Code Gen Options:: Specifying conventions for function calls, data layout
142 * Environment Variables:: Env vars that affect GCC.
143 * Precompiled Headers:: Compiling a header once, and using it many times.
144 * Running Protoize:: Automatically adding or removing function prototypes.
150 @section Option Summary
152 Here is a summary of all the options, grouped by type. Explanations are
153 in the following sections.
156 @item Overall Options
157 @xref{Overall Options,,Options Controlling the Kind of Output}.
158 @gccoptlist{-c -S -E -o @var{file} -combine -pipe -pass-exit-codes @gol
159 -x @var{language} -v -### --help --target-help --version}
161 @item C Language Options
162 @xref{C Dialect Options,,Options Controlling C Dialect}.
163 @gccoptlist{-ansi -std=@var{standard} -aux-info @var{filename} @gol
164 -fno-asm -fno-builtin -fno-builtin-@var{function} @gol
165 -fhosted -ffreestanding -fms-extensions @gol
166 -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol
167 -fallow-single-precision -fcond-mismatch @gol
168 -fsigned-bitfields -fsigned-char @gol
169 -funsigned-bitfields -funsigned-char}
171 @item C++ Language Options
172 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
173 @gccoptlist{-fabi-version=@var{n} -fno-access-control -fcheck-new @gol
174 -fconserve-space -fno-const-strings @gol
175 -fno-elide-constructors @gol
176 -fno-enforce-eh-specs @gol
177 -ffor-scope -fno-for-scope -fno-gnu-keywords @gol
178 -fno-implicit-templates @gol
179 -fno-implicit-inline-templates @gol
180 -fno-implement-inlines -fms-extensions @gol
181 -fno-nonansi-builtins -fno-operator-names @gol
182 -fno-optional-diags -fpermissive @gol
183 -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
184 -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
185 -fno-default-inline -Wabi -Wctor-dtor-privacy @gol
186 -Wnon-virtual-dtor -Wreorder @gol
187 -Weffc++ -Wno-deprecated @gol
188 -Wno-non-template-friend -Wold-style-cast @gol
189 -Woverloaded-virtual -Wno-pmf-conversions @gol
190 -Wsign-promo -Wsynth}
192 @item Objective-C Language Options
193 @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}.
195 -fconstant-string-class=@var{class-name} @gol
196 -fgnu-runtime -fnext-runtime @gol
197 -fno-nil-receivers @gol
198 -fobjc-exceptions @gol
199 -freplace-objc-classes @gol
202 -Wno-protocol -Wselector -Wundeclared-selector}
204 @item Language Independent Options
205 @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}.
206 @gccoptlist{-fmessage-length=@var{n} @gol
207 -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}}
209 @item Warning Options
210 @xref{Warning Options,,Options to Request or Suppress Warnings}.
211 @gccoptlist{-fsyntax-only -pedantic -pedantic-errors @gol
212 -w -Wextra -Wall -Waggregate-return @gol
213 -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
214 -Wconversion -Wno-deprecated-declarations @gol
215 -Wdisabled-optimization -Wno-div-by-zero -Wendif-labels @gol
216 -Werror -Werror-implicit-function-declaration @gol
217 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
218 -Wno-format-extra-args -Wformat-nonliteral @gol
219 -Wformat-security -Wformat-y2k @gol
220 -Wimplicit -Wimplicit-function-declaration -Wimplicit-int @gol
221 -Wimport -Wno-import -Winit-self -Winline @gol
222 -Wno-invalid-offsetof -Winvalid-pch @gol
223 -Wlarger-than-@var{len} -Wlong-long @gol
224 -Wmain -Wmissing-braces @gol
225 -Wmissing-format-attribute -Wmissing-include-dirs @gol
226 -Wmissing-noreturn @gol
227 -Wno-multichar -Wnonnull -Wpacked -Wpadded @gol
228 -Wparentheses -Wpointer-arith -Wredundant-decls @gol
229 -Wreturn-type -Wsequence-point -Wshadow @gol
230 -Wsign-compare -Wstrict-aliasing -Wstrict-aliasing=2 @gol
231 -Wswitch -Wswitch-default -Wswitch-enum @gol
232 -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
233 -Wunknown-pragmas -Wunreachable-code @gol
234 -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol
235 -Wunused-value -Wunused-variable -Wwrite-strings @gol
238 @item C-only Warning Options
239 @gccoptlist{-Wbad-function-cast -Wmissing-declarations @gol
240 -Wmissing-prototypes -Wnested-externs -Wold-style-definition @gol
241 -Wstrict-prototypes -Wtraditional @gol
242 -Wdeclaration-after-statement}
244 @item Debugging Options
245 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
246 @gccoptlist{-d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol
247 -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol
248 -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
250 -fdump-tree-original@r{[}-@var{n}@r{]} @gol
251 -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol
252 -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol
253 -fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias @gol
255 -fdump-tree-ssa@r{[}-@var{n}@r{]} -fdump-tree-pre@r{[}-@var{n}@r{]} @gol
256 -fdump-tree-ccp@r{[}-@var{n}@r{]} -fdump-tree-dce@r{[}-@var{n}@r{]} @gol
257 -fdump-tree-gimple@r{[}-raw@r{]} -fdump-tree-mudflap@r{[}-@var{n}@r{]} @gol
258 -fdump-tree-dom@r{[}-@var{n}@r{]} @gol
259 -fdump-tree-dse@r{[}-@var{n}@r{]} @gol
260 -fdump-tree-phiopt@r{[}-@var{n}@r{]} @gol
261 -fdump-tree-forwprop@r{[}-@var{n}@r{]} @gol
262 -fdump-tree-copyrename@r{[}-@var{n}@r{]} @gol
264 -fdump-tree-sra@r{[}-@var{n}@r{]} @gol
265 -fdump-tree-fre@r{[}-@var{n}@r{]} @gol
266 -feliminate-dwarf2-dups -feliminate-unused-debug-types @gol
267 -feliminate-unused-debug-symbols -fmem-report -fprofile-arcs -ftree-based-profiling @gol
268 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
269 -ftest-coverage -ftime-report -fvar-tracking @gol
270 -g -g@var{level} -gcoff -gdwarf-2 @gol
271 -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol
272 -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
273 -print-multi-directory -print-multi-lib @gol
274 -print-prog-name=@var{program} -print-search-dirs -Q @gol
277 @item Optimization Options
278 @xref{Optimize Options,,Options that Control Optimization}.
279 @gccoptlist{-falign-functions=@var{n} -falign-jumps=@var{n} @gol
280 -falign-labels=@var{n} -falign-loops=@var{n} @gol
281 -fbounds-check -fmudflap -fmudflapth -fmudflapir @gol
282 -fbranch-probabilities -fprofile-values -fvpt -fbranch-target-load-optimize @gol
283 -fbranch-target-load-optimize2 -fbtr-bb-exclusive @gol
284 -fcaller-saves -fcprop-registers @gol
285 -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol
286 -fdelayed-branch -fdelete-null-pointer-checks @gol
287 -fexpensive-optimizations -ffast-math -ffloat-store @gol
288 -fforce-addr -fforce-mem -ffunction-sections @gol
289 -fgcse -fgcse-lm -fgcse-sm -fgcse-las -fgcse-after-reload @gol
290 -floop-optimize -fcrossjumping -fif-conversion -fif-conversion2 @gol
291 -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol
292 -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol
293 -fmodulo-sched -fmove-all-movables -fnew-ra -fno-branch-count-reg @gol
294 -fno-default-inline -fno-defer-pop -floop-optimize2 -fmove-loop-invariants @gol
295 -fno-function-cse -fno-guess-branch-probability @gol
296 -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol
297 -funsafe-math-optimizations -ffinite-math-only @gol
298 -fno-trapping-math -fno-zero-initialized-in-bss @gol
299 -fomit-frame-pointer -foptimize-register-move @gol
300 -foptimize-sibling-calls -fprefetch-loop-arrays @gol
301 -fprofile-generate -fprofile-use @gol
302 -freduce-all-givs -fregmove -frename-registers @gol
303 -freorder-blocks -freorder-blocks-and-partition -freorder-functions @gol
304 -frerun-cse-after-loop -frerun-loop-opt @gol
305 -frounding-math -fschedule-insns -fschedule-insns2 @gol
306 -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol
307 -fsched-spec-load-dangerous @gol
308 -fsched-stalled-insns=@var{n} -sched-stalled-insns-dep=@var{n} @gol
309 -fsched2-use-superblocks @gol
310 -fsched2-use-traces -fsignaling-nans @gol
311 -fsingle-precision-constant @gol
312 -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps @gol
313 -funroll-all-loops -funroll-loops -fpeel-loops @gol
314 -funswitch-loops -fold-unroll-loops -fold-unroll-all-loops @gol
315 -ftree-pre -ftree-ccp -ftree-dce -ftree-loop-optimize @gol
316 -ftree-dominator-opts -ftree-dse -ftree-copyrename @gol
317 -ftree-ch -ftree-sra -ftree-ter -ftree-lrs -ftree-fre @gol
318 --param @var{name}=@var{value}
319 -O -O0 -O1 -O2 -O3 -Os}
321 @item Preprocessor Options
322 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
323 @gccoptlist{-A@var{question}=@var{answer} @gol
324 -A-@var{question}@r{[}=@var{answer}@r{]} @gol
325 -C -dD -dI -dM -dN @gol
326 -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol
327 -idirafter @var{dir} @gol
328 -include @var{file} -imacros @var{file} @gol
329 -iprefix @var{file} -iwithprefix @var{dir} @gol
330 -iwithprefixbefore @var{dir} -isystem @var{dir} @gol
331 -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol
332 -P -fworking-directory -remap @gol
333 -trigraphs -undef -U@var{macro} -Wp,@var{option} @gol
334 -Xpreprocessor @var{option}}
336 @item Assembler Option
337 @xref{Assembler Options,,Passing Options to the Assembler}.
338 @gccoptlist{-Wa,@var{option} -Xassembler @var{option}}
341 @xref{Link Options,,Options for Linking}.
342 @gccoptlist{@var{object-file-name} -l@var{library} @gol
343 -nostartfiles -nodefaultlibs -nostdlib -pie @gol
344 -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol
345 -Wl,@var{option} -Xlinker @var{option} @gol
348 @item Directory Options
349 @xref{Directory Options,,Options for Directory Search}.
350 @gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-}
353 @c I wrote this xref this way to avoid overfull hbox. -- rms
354 @xref{Target Options}.
355 @gccoptlist{-V @var{version} -b @var{machine}}
357 @item Machine Dependent Options
358 @xref{Submodel Options,,Hardware Models and Configurations}.
359 @c This list is ordered alphanumerically by subsection name.
360 @c Try and put the significant identifier (CPU or system) first,
361 @c so users have a clue at guessing where the ones they want will be.
364 @gccoptlist{-EB -EL @gol
365 -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol
366 -mdata=@var{data-section} -mrodata=@var{readonly-data-section}}
369 @gccoptlist{-mapcs-frame -mno-apcs-frame @gol
370 -mabi=@var{name} @gol
371 -mapcs-stack-check -mno-apcs-stack-check @gol
372 -mapcs-float -mno-apcs-float @gol
373 -mapcs-reentrant -mno-apcs-reentrant @gol
374 -msched-prolog -mno-sched-prolog @gol
375 -mlittle-endian -mbig-endian -mwords-little-endian @gol
376 -mfloat-abi=@var{name} -msoft-float -mhard-float -mfpe @gol
377 -mthumb-interwork -mno-thumb-interwork @gol
378 -mcpu=@var{name} -march=@var{name} -mfpu=@var{name} @gol
379 -mstructure-size-boundary=@var{n} @gol
380 -mabort-on-noreturn @gol
381 -mlong-calls -mno-long-calls @gol
382 -msingle-pic-base -mno-single-pic-base @gol
383 -mpic-register=@var{reg} @gol
384 -mnop-fun-dllimport @gol
385 -mcirrus-fix-invalid-insns -mno-cirrus-fix-invalid-insns @gol
386 -mpoke-function-name @gol
388 -mtpcs-frame -mtpcs-leaf-frame @gol
389 -mcaller-super-interworking -mcallee-super-interworking}
392 @gccoptlist{-mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol
393 -mcall-prologues -mno-tablejump -mtiny-stack -mint8}
396 @gccoptlist{-mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol
397 -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol
398 -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol
399 -mstack-align -mdata-align -mconst-align @gol
400 -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol
401 -melf -maout -melinux -mlinux -sim -sim2 @gol
402 -mmul-bug-workaround -mno-mul-bug-workaround}
404 @emph{Darwin Options}
405 @gccoptlist{-all_load -allowable_client -arch -arch_errors_fatal @gol
406 -arch_only -bind_at_load -bundle -bundle_loader @gol
407 -client_name -compatibility_version -current_version @gol
408 -dependency-file -dylib_file -dylinker_install_name @gol
409 -dynamic -dynamiclib -exported_symbols_list @gol
410 -filelist -flat_namespace -force_cpusubtype_ALL @gol
411 -force_flat_namespace -headerpad_max_install_names @gol
412 -image_base -init -install_name -keep_private_externs @gol
413 -multi_module -multiply_defined -multiply_defined_unused @gol
414 -noall_load -nofixprebinding -nomultidefs -noprebind -noseglinkedit @gol
415 -pagezero_size -prebind -prebind_all_twolevel_modules @gol
416 -private_bundle -read_only_relocs -sectalign @gol
417 -sectobjectsymbols -whyload -seg1addr @gol
418 -sectcreate -sectobjectsymbols -sectorder @gol
419 -seg_addr_table -seg_addr_table_filename -seglinkedit @gol
420 -segprot -segs_read_only_addr -segs_read_write_addr @gol
421 -single_module -static -sub_library -sub_umbrella @gol
422 -twolevel_namespace -umbrella -undefined @gol
423 -unexported_symbols_list -weak_reference_mismatches @gol
426 @emph{DEC Alpha Options}
427 @gccoptlist{-mno-fp-regs -msoft-float -malpha-as -mgas @gol
428 -mieee -mieee-with-inexact -mieee-conformant @gol
429 -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol
430 -mtrap-precision=@var{mode} -mbuild-constants @gol
431 -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol
432 -mbwx -mmax -mfix -mcix @gol
433 -mfloat-vax -mfloat-ieee @gol
434 -mexplicit-relocs -msmall-data -mlarge-data @gol
435 -msmall-text -mlarge-text @gol
436 -mmemory-latency=@var{time}}
438 @emph{DEC Alpha/VMS Options}
439 @gccoptlist{-mvms-return-codes}
442 @gccoptlist{-mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 @gol
443 -mhard-float -msoft-float @gol
444 -malloc-cc -mfixed-cc -mdword -mno-dword @gol
445 -mdouble -mno-double @gol
446 -mmedia -mno-media -mmuladd -mno-muladd @gol
447 -mfdpic -minline-plt -mgprel-ro -multilib-library-pic -mlinked-fp @gol
448 -mlibrary-pic -macc-4 -macc-8 @gol
449 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
450 -mscc -mno-scc -mcond-exec -mno-cond-exec @gol
451 -mvliw-branch -mno-vliw-branch @gol
452 -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
453 -mno-nested-cond-exec -mtomcat-stats @gol
456 @emph{H8/300 Options}
457 @gccoptlist{-mrelax -mh -ms -mn -mint32 -malign-300}
460 @gccoptlist{-march=@var{architecture-type} @gol
461 -mbig-switch -mdisable-fpregs -mdisable-indexing @gol
462 -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol
463 -mjump-in-delay -mlinker-opt -mlong-calls @gol
464 -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol
465 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol
466 -mno-jump-in-delay -mno-long-load-store @gol
467 -mno-portable-runtime -mno-soft-float @gol
468 -mno-space-regs -msoft-float -mpa-risc-1-0 @gol
469 -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol
470 -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio @gol
471 -nolibdld -static -threads}
473 @emph{i386 and x86-64 Options}
474 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
475 -mfpmath=@var{unit} @gol
476 -masm=@var{dialect} -mno-fancy-math-387 @gol
477 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol
478 -mno-wide-multiply -mrtd -malign-double @gol
479 -mpreferred-stack-boundary=@var{num} @gol
480 -mmmx -msse -msse2 -msse3 -m3dnow @gol
481 -mthreads -mno-align-stringops -minline-all-stringops @gol
482 -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol
483 -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer @gol
484 -mno-red-zone -mno-tls-direct-seg-refs @gol
485 -mcmodel=@var{code-model} @gol
489 @gccoptlist{-mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol
490 -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol
491 -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol
492 -minline-float-divide-max-throughput @gol
493 -minline-int-divide-min-latency @gol
494 -minline-int-divide-max-throughput -mno-dwarf2-asm @gol
495 -mfixed-range=@var{register-range}}
497 @emph{M32R/D Options}
498 @gccoptlist{-m32r2 -m32rx -m32r @gol
500 -malign-loops -mno-align-loops @gol
501 -missue-rate=@var{number} @gol
502 -mbranch-cost=@var{number} @gol
503 -mmodel=@var{code-size-model-type} @gol
504 -msdata=@var{sdata-type} @gol
505 -mno-flush-func -mflush-func=@var{name} @gol
506 -mno-flush-trap -mflush-trap=@var{number} @gol
509 @emph{M680x0 Options}
510 @gccoptlist{-m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol
511 -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol
512 -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol
513 -malign-int -mstrict-align -msep-data -mno-sep-data @gol
514 -mshared-library-id=n -mid-shared-library -mno-id-shared-library}
516 @emph{M68hc1x Options}
517 @gccoptlist{-m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol
518 -mauto-incdec -minmax -mlong-calls -mshort @gol
519 -msoft-reg-count=@var{count}}
522 @gccoptlist{-mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol
523 -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol
524 -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol
525 -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol
526 -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment}
529 @gccoptlist{-EL -EB -march=@var{arch} -mtune=@var{arch} @gol
530 -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips64 @gol
531 -mips16 -mno-mips16 -mabi=@var{abi} -mabicalls -mno-abicalls @gol
532 -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfp64 @gol
533 -mhard-float -msoft-float -msingle-float -mdouble-float @gol
534 -mint64 -mlong64 -mlong32 @gol
535 -G@var{num} -membedded-data -mno-embedded-data @gol
536 -muninit-const-in-rodata -mno-uninit-const-in-rodata @gol
537 -msplit-addresses -mno-split-addresses @gol
538 -mexplicit-relocs -mno-explicit-relocs @gol
539 -mrnames -mno-rnames @gol
540 -mcheck-zero-division -mno-check-zero-division @gol
541 -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls @gol
542 -mmad -mno-mad -mfused-madd -mno-fused-madd -nocpp @gol
543 -mfix-r4000 -mno-fix-r4000 -mfix-r4400 -mno-fix-r4400 @gol
544 -mfix-vr4120 -mno-fix-vr4120 -mfix-sb1 -mno-fix-sb1 @gol
545 -mflush-func=@var{func} -mno-flush-func @gol
546 -mbranch-likely -mno-branch-likely @gol
547 -mfp-exceptions -mno-fp-exceptions @gol
548 -mvr4130-align -mno-vr4130-align}
551 @gccoptlist{-mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol
552 -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol
553 -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol
554 -mno-base-addresses -msingle-exit -mno-single-exit}
556 @emph{MN10300 Options}
557 @gccoptlist{-mmult-bug -mno-mult-bug @gol
558 -mam33 -mno-am33 @gol
559 -mam33-2 -mno-am33-2 @gol
563 @gccoptlist{-m32032 -m32332 -m32532 -m32081 -m32381 @gol
564 -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol
565 -mregparam -mnoregparam -msb -mnosb @gol
566 -mbitfield -mnobitfield -mhimem -mnohimem}
568 @emph{PDP-11 Options}
569 @gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
570 -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol
571 -mint16 -mno-int32 -mfloat32 -mno-float64 @gol
572 -mfloat64 -mno-float32 -mabshi -mno-abshi @gol
573 -mbranch-expensive -mbranch-cheap @gol
574 -msplit -mno-split -munix-asm -mdec-asm}
576 @emph{PowerPC Options}
577 See RS/6000 and PowerPC Options.
579 @emph{RS/6000 and PowerPC Options}
580 @gccoptlist{-mcpu=@var{cpu-type} @gol
581 -mtune=@var{cpu-type} @gol
582 -mpower -mno-power -mpower2 -mno-power2 @gol
583 -mpowerpc -mpowerpc64 -mno-powerpc @gol
584 -maltivec -mno-altivec @gol
585 -mpowerpc-gpopt -mno-powerpc-gpopt @gol
586 -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol
587 -mnew-mnemonics -mold-mnemonics @gol
588 -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol
589 -m64 -m32 -mxl-call -mno-xl-call -mpe @gol
590 -malign-power -malign-natural @gol
591 -msoft-float -mhard-float -mmultiple -mno-multiple @gol
592 -mstring -mno-string -mupdate -mno-update @gol
593 -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol
594 -mstrict-align -mno-strict-align -mrelocatable @gol
595 -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol
596 -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol
597 -mdynamic-no-pic @gol
598 -mprioritize-restricted-insns=@var{priority} @gol
599 -msched-costly-dep=@var{dependence_type} @gol
600 -minsert-sched-nops=@var{scheme} @gol
601 -mcall-sysv -mcall-netbsd @gol
602 -maix-struct-return -msvr4-struct-return @gol
603 -mabi=altivec -mabi=no-altivec @gol
604 -mabi=spe -mabi=no-spe @gol
605 -misel=yes -misel=no @gol
606 -mspe=yes -mspe=no @gol
607 -mfloat-gprs=yes -mfloat-gprs=no @gol
608 -mprototype -mno-prototype @gol
609 -msim -mmvme -mads -myellowknife -memb -msdata @gol
610 -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread}
612 @emph{S/390 and zSeries Options}
613 @gccoptlist{-mtune=@var{cpu-type} -march=@var{cpu-type} @gol
614 -mhard-float -msoft-float -mbackchain -mno-backchain @gol
615 -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol
616 -m64 -m31 -mdebug -mno-debug -mesa -mzarch @gol
617 -mtpf-trace -mno-tpf-trace -mfused-madd -mno-fused-madd}
620 @gccoptlist{-m1 -m2 -m2e -m3 -m3e @gol
621 -m4-nofpu -m4-single-only -m4-single -m4 @gol
622 -m5-64media -m5-64media-nofpu @gol
623 -m5-32media -m5-32media-nofpu @gol
624 -m5-compact -m5-compact-nofpu @gol
625 -mb -ml -mdalign -mrelax @gol
626 -mbigtable -mfmovd -mhitachi -mnomacsave @gol
627 -mieee -misize -mpadstruct -mspace @gol
628 -mprefergot -musermode}
631 @gccoptlist{-mcpu=@var{cpu-type} @gol
632 -mtune=@var{cpu-type} @gol
633 -mcmodel=@var{code-model} @gol
634 -m32 -m64 -mapp-regs -mno-app-regs @gol
635 -mfaster-structs -mno-faster-structs @gol
636 -mfpu -mno-fpu -mhard-float -msoft-float @gol
637 -mhard-quad-float -msoft-quad-float @gol
638 -mimpure-text -mno-impure-text -mlittle-endian @gol
639 -mstack-bias -mno-stack-bias @gol
640 -munaligned-doubles -mno-unaligned-doubles @gol
641 -mv8plus -mno-v8plus -mvis -mno-vis}
643 @emph{System V Options}
644 @gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
646 @emph{TMS320C3x/C4x Options}
647 @gccoptlist{-mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol
648 -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol
649 -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol
650 -mparallel-insns -mparallel-mpy -mpreserve-float}
653 @gccoptlist{-mlong-calls -mno-long-calls -mep -mno-ep @gol
654 -mprolog-function -mno-prolog-function -mspace @gol
655 -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol
656 -mapp-regs -mno-app-regs @gol
657 -mdisable-callt -mno-disable-callt @gol
663 @gccoptlist{-mg -mgnu -munix}
665 @emph{x86-64 Options}
666 See i386 and x86-64 Options.
668 @emph{Xstormy16 Options}
671 @emph{Xtensa Options}
672 @gccoptlist{-mconst16 -mno-const16 @gol
673 -mfused-madd -mno-fused-madd @gol
674 -mtext-section-literals -mno-text-section-literals @gol
675 -mtarget-align -mno-target-align @gol
676 -mlongcalls -mno-longcalls}
678 @emph{zSeries Options}
679 See S/390 and zSeries Options.
681 @item Code Generation Options
682 @xref{Code Gen Options,,Options for Code Generation Conventions}.
683 @gccoptlist{-fcall-saved-@var{reg} -fcall-used-@var{reg} @gol
684 -ffixed-@var{reg} -fexceptions @gol
685 -fnon-call-exceptions -funwind-tables @gol
686 -fasynchronous-unwind-tables @gol
687 -finhibit-size-directive -finstrument-functions @gol
688 -fno-common -fno-ident @gol
689 -fpcc-struct-return -fpic -fPIC -fpie -fPIE @gol
690 -freg-struct-return -fshared-data -fshort-enums @gol
691 -fshort-double -fshort-wchar @gol
692 -fverbose-asm -fpack-struct -fstack-check @gol
693 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
694 -fargument-alias -fargument-noalias @gol
695 -fargument-noalias-global -fleading-underscore @gol
696 -ftls-model=@var{model} @gol
697 -ftrapv -fwrapv -fbounds-check}
701 * Overall Options:: Controlling the kind of output:
702 an executable, object files, assembler files,
703 or preprocessed source.
704 * C Dialect Options:: Controlling the variant of C language compiled.
705 * C++ Dialect Options:: Variations on C++.
706 * Objective-C Dialect Options:: Variations on Objective-C.
707 * Language Independent Options:: Controlling how diagnostics should be
709 * Warning Options:: How picky should the compiler be?
710 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
711 * Optimize Options:: How much optimization?
712 * Preprocessor Options:: Controlling header files and macro definitions.
713 Also, getting dependency information for Make.
714 * Assembler Options:: Passing options to the assembler.
715 * Link Options:: Specifying libraries and so on.
716 * Directory Options:: Where to find header files and libraries.
717 Where to find the compiler executable files.
718 * Spec Files:: How to pass switches to sub-processes.
719 * Target Options:: Running a cross-compiler, or an old version of GCC.
722 @node Overall Options
723 @section Options Controlling the Kind of Output
725 Compilation can involve up to four stages: preprocessing, compilation
726 proper, assembly and linking, always in that order. GCC is capable of
727 preprocessing and compiling several files either into several
728 assembler input files, or into one assembler input file; then each
729 assembler input file produces an object file, and linking combines all
730 the object files (those newly compiled, and those specified as input)
731 into an executable file.
733 @cindex file name suffix
734 For any given input file, the file name suffix determines what kind of
739 C source code which must be preprocessed.
742 C source code which should not be preprocessed.
745 C++ source code which should not be preprocessed.
748 Objective-C source code. Note that you must link with the library
749 @file{libobjc.a} to make an Objective-C program work.
752 Objective-C source code which should not be preprocessed.
755 C or C++ header file to be turned into a precompiled header.
759 @itemx @var{file}.cxx
760 @itemx @var{file}.cpp
761 @itemx @var{file}.CPP
762 @itemx @var{file}.c++
764 C++ source code which must be preprocessed. Note that in @samp{.cxx},
765 the last two letters must both be literally @samp{x}. Likewise,
766 @samp{.C} refers to a literal capital C@.
770 C++ header file to be turned into a precompiled header.
773 @itemx @var{file}.for
774 @itemx @var{file}.FOR
775 Fortran source code which should not be preprocessed.
778 @itemx @var{file}.fpp
779 @itemx @var{file}.FPP
780 Fortran source code which must be preprocessed (with the traditional
784 Fortran source code which must be preprocessed with a RATFOR
785 preprocessor (not included with GCC)@.
788 @itemx @var{file}.f95
789 Fortran 90/95 source code which should not be preprocessed.
791 @c FIXME: Descriptions of Java file types.
798 Ada source code file which contains a library unit declaration (a
799 declaration of a package, subprogram, or generic, or a generic
800 instantiation), or a library unit renaming declaration (a package,
801 generic, or subprogram renaming declaration). Such files are also
804 @itemx @var{file}.adb
805 Ada source code file containing a library unit body (a subprogram or
806 package body). Such files are also called @dfn{bodies}.
808 @c GCC also knows about some suffixes for languages not yet included:
817 Assembler code which must be preprocessed.
820 An object file to be fed straight into linking.
821 Any file name with no recognized suffix is treated this way.
825 You can specify the input language explicitly with the @option{-x} option:
828 @item -x @var{language}
829 Specify explicitly the @var{language} for the following input files
830 (rather than letting the compiler choose a default based on the file
831 name suffix). This option applies to all following input files until
832 the next @option{-x} option. Possible values for @var{language} are:
834 c c-header cpp-output
835 c++ c++-header c++-cpp-output
836 objective-c objective-c-header objc-cpp-output
837 assembler assembler-with-cpp
839 f77 f77-cpp-input ratfor
846 Turn off any specification of a language, so that subsequent files are
847 handled according to their file name suffixes (as they are if @option{-x}
848 has not been used at all).
850 @item -pass-exit-codes
851 @opindex pass-exit-codes
852 Normally the @command{gcc} program will exit with the code of 1 if any
853 phase of the compiler returns a non-success return code. If you specify
854 @option{-pass-exit-codes}, the @command{gcc} program will instead return with
855 numerically highest error produced by any phase that returned an error
859 If you only want some of the stages of compilation, you can use
860 @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and
861 one of the options @option{-c}, @option{-S}, or @option{-E} to say where
862 @command{gcc} is to stop. Note that some combinations (for example,
863 @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all.
868 Compile or assemble the source files, but do not link. The linking
869 stage simply is not done. The ultimate output is in the form of an
870 object file for each source file.
872 By default, the object file name for a source file is made by replacing
873 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
875 Unrecognized input files, not requiring compilation or assembly, are
880 Stop after the stage of compilation proper; do not assemble. The output
881 is in the form of an assembler code file for each non-assembler input
884 By default, the assembler file name for a source file is made by
885 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
887 Input files that don't require compilation are ignored.
891 Stop after the preprocessing stage; do not run the compiler proper. The
892 output is in the form of preprocessed source code, which is sent to the
895 Input files which don't require preprocessing are ignored.
897 @cindex output file option
900 Place output in file @var{file}. This applies regardless to whatever
901 sort of output is being produced, whether it be an executable file,
902 an object file, an assembler file or preprocessed C code.
904 If @option{-o} is not specified, the default is to put an executable
905 file in @file{a.out}, the object file for
906 @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its
907 assembler file in @file{@var{source}.s}, a precompiled header file in
908 @file{@var{source}.@var{suffix}.gch}, and all preprocessed C source on
913 Print (on standard error output) the commands executed to run the stages
914 of compilation. Also print the version number of the compiler driver
915 program and of the preprocessor and the compiler proper.
919 Like @option{-v} except the commands are not executed and all command
920 arguments are quoted. This is useful for shell scripts to capture the
921 driver-generated command lines.
925 Use pipes rather than temporary files for communication between the
926 various stages of compilation. This fails to work on some systems where
927 the assembler is unable to read from a pipe; but the GNU assembler has
932 If you are compiling multiple source files, this option tells the driver
933 to pass all the source files to the compiler at once (for those
934 languages for which the compiler can handle this). This will allow
935 intermodule analysis (IMA) to be performed by the compiler. Currently the only
936 language for which this is supported is C. If you pass source files for
937 multiple languages to the driver, using this option, the driver will invoke
938 the compiler(s) that support IMA once each, passing each compiler all the
939 source files appropriate for it. For those languages that do not support
940 IMA this option will be ignored, and the compiler will be invoked once for
941 each source file in that language. If you use this option in conjunction
942 with -save-temps, the compiler will generate multiple pre-processed files
943 (one for each source file), but only one (combined) .o or .s file.
947 Print (on the standard output) a description of the command line options
948 understood by @command{gcc}. If the @option{-v} option is also specified
949 then @option{--help} will also be passed on to the various processes
950 invoked by @command{gcc}, so that they can display the command line options
951 they accept. If the @option{-Wextra} option is also specified then command
952 line options which have no documentation associated with them will also
957 Print (on the standard output) a description of target specific command
958 line options for each tool.
962 Display the version number and copyrights of the invoked GCC.
966 @section Compiling C++ Programs
968 @cindex suffixes for C++ source
969 @cindex C++ source file suffixes
970 C++ source files conventionally use one of the suffixes @samp{.C},
971 @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or
972 @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; and
973 preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes
974 files with these names and compiles them as C++ programs even if you
975 call the compiler the same way as for compiling C programs (usually
976 with the name @command{gcc}).
980 However, C++ programs often require class libraries as well as a
981 compiler that understands the C++ language---and under some
982 circumstances, you might want to compile programs or header files from
983 standard input, or otherwise without a suffix that flags them as C++
984 programs. You might also like to precompile a C header file with a
985 @samp{.h} extension to be used in C++ compilations. @command{g++} is a
986 program that calls GCC with the default language set to C++, and
987 automatically specifies linking against the C++ library. On many
988 systems, @command{g++} is also installed with the name @command{c++}.
990 @cindex invoking @command{g++}
991 When you compile C++ programs, you may specify many of the same
992 command-line options that you use for compiling programs in any
993 language; or command-line options meaningful for C and related
994 languages; or options that are meaningful only for C++ programs.
995 @xref{C Dialect Options,,Options Controlling C Dialect}, for
996 explanations of options for languages related to C@.
997 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
998 explanations of options that are meaningful only for C++ programs.
1000 @node C Dialect Options
1001 @section Options Controlling C Dialect
1002 @cindex dialect options
1003 @cindex language dialect options
1004 @cindex options, dialect
1006 The following options control the dialect of C (or languages derived
1007 from C, such as C++ and Objective-C) that the compiler accepts:
1010 @cindex ANSI support
1014 In C mode, support all ISO C90 programs. In C++ mode,
1015 remove GNU extensions that conflict with ISO C++.
1017 This turns off certain features of GCC that are incompatible with ISO
1018 C90 (when compiling C code), or of standard C++ (when compiling C++ code),
1019 such as the @code{asm} and @code{typeof} keywords, and
1020 predefined macros such as @code{unix} and @code{vax} that identify the
1021 type of system you are using. It also enables the undesirable and
1022 rarely used ISO trigraph feature. For the C compiler,
1023 it disables recognition of C++ style @samp{//} comments as well as
1024 the @code{inline} keyword.
1026 The alternate keywords @code{__asm__}, @code{__extension__},
1027 @code{__inline__} and @code{__typeof__} continue to work despite
1028 @option{-ansi}. You would not want to use them in an ISO C program, of
1029 course, but it is useful to put them in header files that might be included
1030 in compilations done with @option{-ansi}. Alternate predefined macros
1031 such as @code{__unix__} and @code{__vax__} are also available, with or
1032 without @option{-ansi}.
1034 The @option{-ansi} option does not cause non-ISO programs to be
1035 rejected gratuitously. For that, @option{-pedantic} is required in
1036 addition to @option{-ansi}. @xref{Warning Options}.
1038 The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
1039 option is used. Some header files may notice this macro and refrain
1040 from declaring certain functions or defining certain macros that the
1041 ISO standard doesn't call for; this is to avoid interfering with any
1042 programs that might use these names for other things.
1044 Functions which would normally be built in but do not have semantics
1045 defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
1046 functions with @option{-ansi} is used. @xref{Other Builtins,,Other
1047 built-in functions provided by GCC}, for details of the functions
1052 Determine the language standard. This option is currently only
1053 supported when compiling C or C++. A value for this option must be
1054 provided; possible values are
1059 ISO C90 (same as @option{-ansi}).
1061 @item iso9899:199409
1062 ISO C90 as modified in amendment 1.
1068 ISO C99. Note that this standard is not yet fully supported; see
1069 @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The
1070 names @samp{c9x} and @samp{iso9899:199x} are deprecated.
1073 Default, ISO C90 plus GNU extensions (including some C99 features).
1077 ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC,
1078 this will become the default. The name @samp{gnu9x} is deprecated.
1081 The 1998 ISO C++ standard plus amendments.
1084 The same as @option{-std=c++98} plus GNU extensions. This is the
1085 default for C++ code.
1088 Even when this option is not specified, you can still use some of the
1089 features of newer standards in so far as they do not conflict with
1090 previous C standards. For example, you may use @code{__restrict__} even
1091 when @option{-std=c99} is not specified.
1093 The @option{-std} options specifying some version of ISO C have the same
1094 effects as @option{-ansi}, except that features that were not in ISO C90
1095 but are in the specified version (for example, @samp{//} comments and
1096 the @code{inline} keyword in ISO C99) are not disabled.
1098 @xref{Standards,,Language Standards Supported by GCC}, for details of
1099 these standard versions.
1101 @item -aux-info @var{filename}
1103 Output to the given filename prototyped declarations for all functions
1104 declared and/or defined in a translation unit, including those in header
1105 files. This option is silently ignored in any language other than C@.
1107 Besides declarations, the file indicates, in comments, the origin of
1108 each declaration (source file and line), whether the declaration was
1109 implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or
1110 @samp{O} for old, respectively, in the first character after the line
1111 number and the colon), and whether it came from a declaration or a
1112 definition (@samp{C} or @samp{F}, respectively, in the following
1113 character). In the case of function definitions, a K&R-style list of
1114 arguments followed by their declarations is also provided, inside
1115 comments, after the declaration.
1119 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
1120 keyword, so that code can use these words as identifiers. You can use
1121 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
1122 instead. @option{-ansi} implies @option{-fno-asm}.
1124 In C++, this switch only affects the @code{typeof} keyword, since
1125 @code{asm} and @code{inline} are standard keywords. You may want to
1126 use the @option{-fno-gnu-keywords} flag instead, which has the same
1127 effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this
1128 switch only affects the @code{asm} and @code{typeof} keywords, since
1129 @code{inline} is a standard keyword in ISO C99.
1132 @itemx -fno-builtin-@var{function}
1133 @opindex fno-builtin
1134 @cindex built-in functions
1135 Don't recognize built-in functions that do not begin with
1136 @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in
1137 functions provided by GCC}, for details of the functions affected,
1138 including those which are not built-in functions when @option{-ansi} or
1139 @option{-std} options for strict ISO C conformance are used because they
1140 do not have an ISO standard meaning.
1142 GCC normally generates special code to handle certain built-in functions
1143 more efficiently; for instance, calls to @code{alloca} may become single
1144 instructions that adjust the stack directly, and calls to @code{memcpy}
1145 may become inline copy loops. The resulting code is often both smaller
1146 and faster, but since the function calls no longer appear as such, you
1147 cannot set a breakpoint on those calls, nor can you change the behavior
1148 of the functions by linking with a different library.
1150 With the @option{-fno-builtin-@var{function}} option
1151 only the built-in function @var{function} is
1152 disabled. @var{function} must not begin with @samp{__builtin_}. If a
1153 function is named this is not built-in in this version of GCC, this
1154 option is ignored. There is no corresponding
1155 @option{-fbuiltin-@var{function}} option; if you wish to enable
1156 built-in functions selectively when using @option{-fno-builtin} or
1157 @option{-ffreestanding}, you may define macros such as:
1160 #define abs(n) __builtin_abs ((n))
1161 #define strcpy(d, s) __builtin_strcpy ((d), (s))
1166 @cindex hosted environment
1168 Assert that compilation takes place in a hosted environment. This implies
1169 @option{-fbuiltin}. A hosted environment is one in which the
1170 entire standard library is available, and in which @code{main} has a return
1171 type of @code{int}. Examples are nearly everything except a kernel.
1172 This is equivalent to @option{-fno-freestanding}.
1174 @item -ffreestanding
1175 @opindex ffreestanding
1176 @cindex hosted environment
1178 Assert that compilation takes place in a freestanding environment. This
1179 implies @option{-fno-builtin}. A freestanding environment
1180 is one in which the standard library may not exist, and program startup may
1181 not necessarily be at @code{main}. The most obvious example is an OS kernel.
1182 This is equivalent to @option{-fno-hosted}.
1184 @xref{Standards,,Language Standards Supported by GCC}, for details of
1185 freestanding and hosted environments.
1187 @item -fms-extensions
1188 @opindex fms-extensions
1189 Accept some non-standard constructs used in Microsoft header files.
1193 Support ISO C trigraphs. The @option{-ansi} option (and @option{-std}
1194 options for strict ISO C conformance) implies @option{-trigraphs}.
1196 @item -no-integrated-cpp
1197 @opindex no-integrated-cpp
1198 Performs a compilation in two passes: preprocessing and compiling. This
1199 option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the
1200 @option{-B} option. The user supplied compilation step can then add in
1201 an additional preprocessing step after normal preprocessing but before
1202 compiling. The default is to use the integrated cpp (internal cpp)
1204 The semantics of this option will change if "cc1", "cc1plus", and
1205 "cc1obj" are merged.
1207 @cindex traditional C language
1208 @cindex C language, traditional
1210 @itemx -traditional-cpp
1211 @opindex traditional-cpp
1212 @opindex traditional
1213 Formerly, these options caused GCC to attempt to emulate a pre-standard
1214 C compiler. They are now only supported with the @option{-E} switch.
1215 The preprocessor continues to support a pre-standard mode. See the GNU
1216 CPP manual for details.
1218 @item -fcond-mismatch
1219 @opindex fcond-mismatch
1220 Allow conditional expressions with mismatched types in the second and
1221 third arguments. The value of such an expression is void. This option
1222 is not supported for C++.
1224 @item -funsigned-char
1225 @opindex funsigned-char
1226 Let the type @code{char} be unsigned, like @code{unsigned char}.
1228 Each kind of machine has a default for what @code{char} should
1229 be. It is either like @code{unsigned char} by default or like
1230 @code{signed char} by default.
1232 Ideally, a portable program should always use @code{signed char} or
1233 @code{unsigned char} when it depends on the signedness of an object.
1234 But many programs have been written to use plain @code{char} and
1235 expect it to be signed, or expect it to be unsigned, depending on the
1236 machines they were written for. This option, and its inverse, let you
1237 make such a program work with the opposite default.
1239 The type @code{char} is always a distinct type from each of
1240 @code{signed char} or @code{unsigned char}, even though its behavior
1241 is always just like one of those two.
1244 @opindex fsigned-char
1245 Let the type @code{char} be signed, like @code{signed char}.
1247 Note that this is equivalent to @option{-fno-unsigned-char}, which is
1248 the negative form of @option{-funsigned-char}. Likewise, the option
1249 @option{-fno-signed-char} is equivalent to @option{-funsigned-char}.
1251 @item -fsigned-bitfields
1252 @itemx -funsigned-bitfields
1253 @itemx -fno-signed-bitfields
1254 @itemx -fno-unsigned-bitfields
1255 @opindex fsigned-bitfields
1256 @opindex funsigned-bitfields
1257 @opindex fno-signed-bitfields
1258 @opindex fno-unsigned-bitfields
1259 These options control whether a bit-field is signed or unsigned, when the
1260 declaration does not use either @code{signed} or @code{unsigned}. By
1261 default, such a bit-field is signed, because this is consistent: the
1262 basic integer types such as @code{int} are signed types.
1265 @node C++ Dialect Options
1266 @section Options Controlling C++ Dialect
1268 @cindex compiler options, C++
1269 @cindex C++ options, command line
1270 @cindex options, C++
1271 This section describes the command-line options that are only meaningful
1272 for C++ programs; but you can also use most of the GNU compiler options
1273 regardless of what language your program is in. For example, you
1274 might compile a file @code{firstClass.C} like this:
1277 g++ -g -frepo -O -c firstClass.C
1281 In this example, only @option{-frepo} is an option meant
1282 only for C++ programs; you can use the other options with any
1283 language supported by GCC@.
1285 Here is a list of options that are @emph{only} for compiling C++ programs:
1289 @item -fabi-version=@var{n}
1290 @opindex fabi-version
1291 Use version @var{n} of the C++ ABI. Version 2 is the version of the
1292 C++ ABI that first appeared in G++ 3.4. Version 1 is the version of
1293 the C++ ABI that first appeared in G++ 3.2. Version 0 will always be
1294 the version that conforms most closely to the C++ ABI specification.
1295 Therefore, the ABI obtained using version 0 will change as ABI bugs
1298 The default is version 2.
1300 @item -fno-access-control
1301 @opindex fno-access-control
1302 Turn off all access checking. This switch is mainly useful for working
1303 around bugs in the access control code.
1307 Check that the pointer returned by @code{operator new} is non-null
1308 before attempting to modify the storage allocated. This check is
1309 normally unnecessary because the C++ standard specifies that
1310 @code{operator new} will only return @code{0} if it is declared
1311 @samp{throw()}, in which case the compiler will always check the
1312 return value even without this option. In all other cases, when
1313 @code{operator new} has a non-empty exception specification, memory
1314 exhaustion is signalled by throwing @code{std::bad_alloc}. See also
1315 @samp{new (nothrow)}.
1317 @item -fconserve-space
1318 @opindex fconserve-space
1319 Put uninitialized or runtime-initialized global variables into the
1320 common segment, as C does. This saves space in the executable at the
1321 cost of not diagnosing duplicate definitions. If you compile with this
1322 flag and your program mysteriously crashes after @code{main()} has
1323 completed, you may have an object that is being destroyed twice because
1324 two definitions were merged.
1326 This option is no longer useful on most targets, now that support has
1327 been added for putting variables into BSS without making them common.
1329 @item -fno-const-strings
1330 @opindex fno-const-strings
1331 Give string constants type @code{char *} instead of type @code{const
1332 char *}. By default, G++ uses type @code{const char *} as required by
1333 the standard. Even if you use @option{-fno-const-strings}, you cannot
1334 actually modify the value of a string constant.
1336 This option might be removed in a future release of G++. For maximum
1337 portability, you should structure your code so that it works with
1338 string constants that have type @code{const char *}.
1340 @item -fno-elide-constructors
1341 @opindex fno-elide-constructors
1342 The C++ standard allows an implementation to omit creating a temporary
1343 which is only used to initialize another object of the same type.
1344 Specifying this option disables that optimization, and forces G++ to
1345 call the copy constructor in all cases.
1347 @item -fno-enforce-eh-specs
1348 @opindex fno-enforce-eh-specs
1349 Don't check for violation of exception specifications at runtime. This
1350 option violates the C++ standard, but may be useful for reducing code
1351 size in production builds, much like defining @samp{NDEBUG}. The compiler
1352 will still optimize based on the exception specifications.
1355 @itemx -fno-for-scope
1357 @opindex fno-for-scope
1358 If @option{-ffor-scope} is specified, the scope of variables declared in
1359 a @i{for-init-statement} is limited to the @samp{for} loop itself,
1360 as specified by the C++ standard.
1361 If @option{-fno-for-scope} is specified, the scope of variables declared in
1362 a @i{for-init-statement} extends to the end of the enclosing scope,
1363 as was the case in old versions of G++, and other (traditional)
1364 implementations of C++.
1366 The default if neither flag is given to follow the standard,
1367 but to allow and give a warning for old-style code that would
1368 otherwise be invalid, or have different behavior.
1370 @item -fno-gnu-keywords
1371 @opindex fno-gnu-keywords
1372 Do not recognize @code{typeof} as a keyword, so that code can use this
1373 word as an identifier. You can use the keyword @code{__typeof__} instead.
1374 @option{-ansi} implies @option{-fno-gnu-keywords}.
1376 @item -fno-implicit-templates
1377 @opindex fno-implicit-templates
1378 Never emit code for non-inline templates which are instantiated
1379 implicitly (i.e.@: by use); only emit code for explicit instantiations.
1380 @xref{Template Instantiation}, for more information.
1382 @item -fno-implicit-inline-templates
1383 @opindex fno-implicit-inline-templates
1384 Don't emit code for implicit instantiations of inline templates, either.
1385 The default is to handle inlines differently so that compiles with and
1386 without optimization will need the same set of explicit instantiations.
1388 @item -fno-implement-inlines
1389 @opindex fno-implement-inlines
1390 To save space, do not emit out-of-line copies of inline functions
1391 controlled by @samp{#pragma implementation}. This will cause linker
1392 errors if these functions are not inlined everywhere they are called.
1394 @item -fms-extensions
1395 @opindex fms-extensions
1396 Disable pedantic warnings about constructs used in MFC, such as implicit
1397 int and getting a pointer to member function via non-standard syntax.
1399 @item -fno-nonansi-builtins
1400 @opindex fno-nonansi-builtins
1401 Disable built-in declarations of functions that are not mandated by
1402 ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit},
1403 @code{index}, @code{bzero}, @code{conjf}, and other related functions.
1405 @item -fno-operator-names
1406 @opindex fno-operator-names
1407 Do not treat the operator name keywords @code{and}, @code{bitand},
1408 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
1409 synonyms as keywords.
1411 @item -fno-optional-diags
1412 @opindex fno-optional-diags
1413 Disable diagnostics that the standard says a compiler does not need to
1414 issue. Currently, the only such diagnostic issued by G++ is the one for
1415 a name having multiple meanings within a class.
1418 @opindex fpermissive
1419 Downgrade some diagnostics about nonconformant code from errors to
1420 warnings. Thus, using @option{-fpermissive} will allow some
1421 nonconforming code to compile.
1425 Enable automatic template instantiation at link time. This option also
1426 implies @option{-fno-implicit-templates}. @xref{Template
1427 Instantiation}, for more information.
1431 Disable generation of information about every class with virtual
1432 functions for use by the C++ runtime type identification features
1433 (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts
1434 of the language, you can save some space by using this flag. Note that
1435 exception handling uses the same information, but it will generate it as
1440 Emit statistics about front-end processing at the end of the compilation.
1441 This information is generally only useful to the G++ development team.
1443 @item -ftemplate-depth-@var{n}
1444 @opindex ftemplate-depth
1445 Set the maximum instantiation depth for template classes to @var{n}.
1446 A limit on the template instantiation depth is needed to detect
1447 endless recursions during template class instantiation. ANSI/ISO C++
1448 conforming programs must not rely on a maximum depth greater than 17.
1450 @item -fuse-cxa-atexit
1451 @opindex fuse-cxa-atexit
1452 Register destructors for objects with static storage duration with the
1453 @code{__cxa_atexit} function rather than the @code{atexit} function.
1454 This option is required for fully standards-compliant handling of static
1455 destructors, but will only work if your C library supports
1456 @code{__cxa_atexit}.
1460 Do not use weak symbol support, even if it is provided by the linker.
1461 By default, G++ will use weak symbols if they are available. This
1462 option exists only for testing, and should not be used by end-users;
1463 it will result in inferior code and has no benefits. This option may
1464 be removed in a future release of G++.
1468 Do not search for header files in the standard directories specific to
1469 C++, but do still search the other standard directories. (This option
1470 is used when building the C++ library.)
1473 In addition, these optimization, warning, and code generation options
1474 have meanings only for C++ programs:
1477 @item -fno-default-inline
1478 @opindex fno-default-inline
1479 Do not assume @samp{inline} for functions defined inside a class scope.
1480 @xref{Optimize Options,,Options That Control Optimization}. Note that these
1481 functions will have linkage like inline functions; they just won't be
1484 @item -Wabi @r{(C++ only)}
1486 Warn when G++ generates code that is probably not compatible with the
1487 vendor-neutral C++ ABI. Although an effort has been made to warn about
1488 all such cases, there are probably some cases that are not warned about,
1489 even though G++ is generating incompatible code. There may also be
1490 cases where warnings are emitted even though the code that is generated
1493 You should rewrite your code to avoid these warnings if you are
1494 concerned about the fact that code generated by G++ may not be binary
1495 compatible with code generated by other compilers.
1497 The known incompatibilities at this point include:
1502 Incorrect handling of tail-padding for bit-fields. G++ may attempt to
1503 pack data into the same byte as a base class. For example:
1506 struct A @{ virtual void f(); int f1 : 1; @};
1507 struct B : public A @{ int f2 : 1; @};
1511 In this case, G++ will place @code{B::f2} into the same byte
1512 as@code{A::f1}; other compilers will not. You can avoid this problem
1513 by explicitly padding @code{A} so that its size is a multiple of the
1514 byte size on your platform; that will cause G++ and other compilers to
1515 layout @code{B} identically.
1518 Incorrect handling of tail-padding for virtual bases. G++ does not use
1519 tail padding when laying out virtual bases. For example:
1522 struct A @{ virtual void f(); char c1; @};
1523 struct B @{ B(); char c2; @};
1524 struct C : public A, public virtual B @{@};
1528 In this case, G++ will not place @code{B} into the tail-padding for
1529 @code{A}; other compilers will. You can avoid this problem by
1530 explicitly padding @code{A} so that its size is a multiple of its
1531 alignment (ignoring virtual base classes); that will cause G++ and other
1532 compilers to layout @code{C} identically.
1535 Incorrect handling of bit-fields with declared widths greater than that
1536 of their underlying types, when the bit-fields appear in a union. For
1540 union U @{ int i : 4096; @};
1544 Assuming that an @code{int} does not have 4096 bits, G++ will make the
1545 union too small by the number of bits in an @code{int}.
1548 Empty classes can be placed at incorrect offsets. For example:
1558 struct C : public B, public A @{@};
1562 G++ will place the @code{A} base class of @code{C} at a nonzero offset;
1563 it should be placed at offset zero. G++ mistakenly believes that the
1564 @code{A} data member of @code{B} is already at offset zero.
1567 Names of template functions whose types involve @code{typename} or
1568 template template parameters can be mangled incorrectly.
1571 template <typename Q>
1572 void f(typename Q::X) @{@}
1574 template <template <typename> class Q>
1575 void f(typename Q<int>::X) @{@}
1579 Instantiations of these templates may be mangled incorrectly.
1583 @item -Wctor-dtor-privacy @r{(C++ only)}
1584 @opindex Wctor-dtor-privacy
1585 Warn when a class seems unusable because all the constructors or
1586 destructors in that class are private, and it has neither friends nor
1587 public static member functions.
1589 @item -Wnon-virtual-dtor @r{(C++ only)}
1590 @opindex Wnon-virtual-dtor
1591 Warn when a class appears to be polymorphic, thereby requiring a virtual
1592 destructor, yet it declares a non-virtual one.
1593 This warning is enabled by @option{-Wall}.
1595 @item -Wreorder @r{(C++ only)}
1597 @cindex reordering, warning
1598 @cindex warning for reordering of member initializers
1599 Warn when the order of member initializers given in the code does not
1600 match the order in which they must be executed. For instance:
1606 A(): j (0), i (1) @{ @}
1610 The compiler will rearrange the member initializers for @samp{i}
1611 and @samp{j} to match the declaration order of the members, emitting
1612 a warning to that effect. This warning is enabled by @option{-Wall}.
1615 The following @option{-W@dots{}} options are not affected by @option{-Wall}.
1618 @item -Weffc++ @r{(C++ only)}
1620 Warn about violations of the following style guidelines from Scott Meyers'
1621 @cite{Effective C++} book:
1625 Item 11: Define a copy constructor and an assignment operator for classes
1626 with dynamically allocated memory.
1629 Item 12: Prefer initialization to assignment in constructors.
1632 Item 14: Make destructors virtual in base classes.
1635 Item 15: Have @code{operator=} return a reference to @code{*this}.
1638 Item 23: Don't try to return a reference when you must return an object.
1642 Also warn about violations of the following style guidelines from
1643 Scott Meyers' @cite{More Effective C++} book:
1647 Item 6: Distinguish between prefix and postfix forms of increment and
1648 decrement operators.
1651 Item 7: Never overload @code{&&}, @code{||}, or @code{,}.
1655 When selecting this option, be aware that the standard library
1656 headers do not obey all of these guidelines; use @samp{grep -v}
1657 to filter out those warnings.
1659 @item -Wno-deprecated @r{(C++ only)}
1660 @opindex Wno-deprecated
1661 Do not warn about usage of deprecated features. @xref{Deprecated Features}.
1663 @item -Wno-non-template-friend @r{(C++ only)}
1664 @opindex Wno-non-template-friend
1665 Disable warnings when non-templatized friend functions are declared
1666 within a template. Since the advent of explicit template specification
1667 support in G++, if the name of the friend is an unqualified-id (i.e.,
1668 @samp{friend foo(int)}), the C++ language specification demands that the
1669 friend declare or define an ordinary, nontemplate function. (Section
1670 14.5.3). Before G++ implemented explicit specification, unqualified-ids
1671 could be interpreted as a particular specialization of a templatized
1672 function. Because this non-conforming behavior is no longer the default
1673 behavior for G++, @option{-Wnon-template-friend} allows the compiler to
1674 check existing code for potential trouble spots and is on by default.
1675 This new compiler behavior can be turned off with
1676 @option{-Wno-non-template-friend} which keeps the conformant compiler code
1677 but disables the helpful warning.
1679 @item -Wold-style-cast @r{(C++ only)}
1680 @opindex Wold-style-cast
1681 Warn if an old-style (C-style) cast to a non-void type is used within
1682 a C++ program. The new-style casts (@samp{static_cast},
1683 @samp{reinterpret_cast}, and @samp{const_cast}) are less vulnerable to
1684 unintended effects and much easier to search for.
1686 @item -Woverloaded-virtual @r{(C++ only)}
1687 @opindex Woverloaded-virtual
1688 @cindex overloaded virtual fn, warning
1689 @cindex warning for overloaded virtual fn
1690 Warn when a function declaration hides virtual functions from a
1691 base class. For example, in:
1698 struct B: public A @{
1703 the @code{A} class version of @code{f} is hidden in @code{B}, and code
1711 will fail to compile.
1713 @item -Wno-pmf-conversions @r{(C++ only)}
1714 @opindex Wno-pmf-conversions
1715 Disable the diagnostic for converting a bound pointer to member function
1718 @item -Wsign-promo @r{(C++ only)}
1719 @opindex Wsign-promo
1720 Warn when overload resolution chooses a promotion from unsigned or
1721 enumeral type to a signed type, over a conversion to an unsigned type of
1722 the same size. Previous versions of G++ would try to preserve
1723 unsignedness, but the standard mandates the current behavior.
1725 @item -Wsynth @r{(C++ only)}
1727 @cindex warning for synthesized methods
1728 @cindex synthesized methods, warning
1729 Warn when G++'s synthesis behavior does not match that of cfront. For
1735 A& operator = (int);
1745 In this example, G++ will synthesize a default @samp{A& operator =
1746 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1749 @node Objective-C Dialect Options
1750 @section Options Controlling Objective-C Dialect
1752 @cindex compiler options, Objective-C
1753 @cindex Objective-C options, command line
1754 @cindex options, Objective-C
1755 (NOTE: This manual does not describe the Objective-C language itself. See
1756 @w{@uref{http://gcc.gnu.org/readings.html}} for references.)
1758 This section describes the command-line options that are only meaningful
1759 for Objective-C programs, but you can also use most of the GNU compiler
1760 options regardless of what language your program is in. For example,
1761 you might compile a file @code{some_class.m} like this:
1764 gcc -g -fgnu-runtime -O -c some_class.m
1768 In this example, @option{-fgnu-runtime} is an option meant only for
1769 Objective-C programs; you can use the other options with any language
1772 Here is a list of options that are @emph{only} for compiling Objective-C
1776 @item -fconstant-string-class=@var{class-name}
1777 @opindex fconstant-string-class
1778 Use @var{class-name} as the name of the class to instantiate for each
1779 literal string specified with the syntax @code{@@"@dots{}"}. The default
1780 class name is @code{NXConstantString} if the GNU runtime is being used, and
1781 @code{NSConstantString} if the NeXT runtime is being used (see below). The
1782 @option{-fconstant-cfstrings} option, if also present, will override the
1783 @option{-fconstant-string-class} setting and cause @code{@@"@dots{}"} literals
1784 to be laid out as constant CoreFoundation strings.
1787 @opindex fgnu-runtime
1788 Generate object code compatible with the standard GNU Objective-C
1789 runtime. This is the default for most types of systems.
1791 @item -fnext-runtime
1792 @opindex fnext-runtime
1793 Generate output compatible with the NeXT runtime. This is the default
1794 for NeXT-based systems, including Darwin and Mac OS X@. The macro
1795 @code{__NEXT_RUNTIME__} is predefined if (and only if) this option is
1798 @item -fno-nil-receivers
1799 @opindex fno-nil-receivers
1800 Assume that all Objective-C message dispatches (e.g.,
1801 @code{[receiver message:arg]}) in this translation unit ensure that the receiver
1802 is not @code{nil}. This allows for more efficient entry points in the runtime to be
1803 used. Currently, this option is only available in conjunction with
1804 the NeXT runtime on Mac OS X 10.3 and later.
1806 @item -fobjc-exceptions
1807 @opindex fobjc-exceptions
1808 Enable syntactic support for structured exception handling in Objective-C,
1809 similar to what is offered by C++ and Java. Currently, this option is only
1810 available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
1818 @@catch (AnObjCClass *exc) @{
1825 @@catch (AnotherClass *exc) @{
1828 @@catch (id allOthers) @{
1838 The @code{@@throw} statement may appear anywhere in an Objective-C or
1839 Objective-C++ program; when used inside of a @code{@@catch} block, the
1840 @code{@@throw} may appear without an argument (as shown above), in which case
1841 the object caught by the @code{@@catch} will be rethrown.
1843 Note that only (pointers to) Objective-C objects may be thrown and
1844 caught using this scheme. When an object is thrown, it will be caught
1845 by the nearest @code{@@catch} clause capable of handling objects of that type,
1846 analogously to how @code{catch} blocks work in C++ and Java. A
1847 @code{@@catch(id @dots{})} clause (as shown above) may also be provided to catch
1848 any and all Objective-C exceptions not caught by previous @code{@@catch}
1851 The @code{@@finally} clause, if present, will be executed upon exit from the
1852 immediately preceding @code{@@try @dots{} @@catch} section. This will happen
1853 regardless of whether any exceptions are thrown, caught or rethrown
1854 inside the @code{@@try @dots{} @@catch} section, analogously to the behavior
1855 of the @code{finally} clause in Java.
1857 There are several caveats to using the new exception mechanism:
1861 Although currently designed to be binary compatible with @code{NS_HANDLER}-style
1862 idioms provided by the @code{NSException} class, the new
1863 exceptions can only be used on Mac OS X 10.3 (Panther) and later
1864 systems, due to additional functionality needed in the (NeXT) Objective-C
1868 As mentioned above, the new exceptions do not support handling
1869 types other than Objective-C objects. Furthermore, when used from
1870 Objective-C++, the Objective-C exception model does not interoperate with C++
1871 exceptions at this time. This means you cannot @code{@@throw} an exception
1872 from Objective-C and @code{catch} it in C++, or vice versa
1873 (i.e., @code{throw @dots{} @@catch}).
1876 The @option{-fobjc-exceptions} switch also enables the use of synchronization
1877 blocks for thread-safe execution:
1880 @@synchronized (ObjCClass *guard) @{
1885 Upon entering the @code{@@synchronized} block, a thread of execution shall
1886 first check whether a lock has been placed on the corresponding @code{guard}
1887 object by another thread. If it has, the current thread shall wait until
1888 the other thread relinquishes its lock. Once @code{guard} becomes available,
1889 the current thread will place its own lock on it, execute the code contained in
1890 the @code{@@synchronized} block, and finally relinquish the lock (thereby
1891 making @code{guard} available to other threads).
1893 Unlike Java, Objective-C does not allow for entire methods to be marked
1894 @code{@@synchronized}. Note that throwing exceptions out of
1895 @code{@@synchronized} blocks is allowed, and will cause the guarding object
1896 to be unlocked properly.
1898 @item -freplace-objc-classes
1899 @opindex freplace-objc-classes
1900 Emit a special marker instructing @command{ld(1)} not to statically link in
1901 the resulting object file, and allow @command{dyld(1)} to load it in at
1902 run time instead. This is used in conjunction with the Fix-and-Continue
1903 debugging mode, where the object file in question may be recompiled and
1904 dynamically reloaded in the course of program execution, without the need
1905 to restart the program itself. Currently, Fix-and-Continue functionality
1906 is only available in conjunction with the NeXT runtime on Mac OS X 10.3
1911 When compiling for the NeXT runtime, the compiler ordinarily replaces calls
1912 to @code{objc_getClass("@dots{}")} (when the name of the class is known at
1913 compile time) with static class references that get initialized at load time,
1914 which improves run-time performance. Specifying the @option{-fzero-link} flag
1915 suppresses this behavior and causes calls to @code{objc_getClass("@dots{}")}
1916 to be retained. This is useful in Zero-Link debugging mode, since it allows
1917 for individual class implementations to be modified during program execution.
1921 Dump interface declarations for all classes seen in the source file to a
1922 file named @file{@var{sourcename}.decl}.
1925 @opindex Wno-protocol
1926 If a class is declared to implement a protocol, a warning is issued for
1927 every method in the protocol that is not implemented by the class. The
1928 default behavior is to issue a warning for every method not explicitly
1929 implemented in the class, even if a method implementation is inherited
1930 from the superclass. If you use the @code{-Wno-protocol} option, then
1931 methods inherited from the superclass are considered to be implemented,
1932 and no warning is issued for them.
1936 Warn if multiple methods of different types for the same selector are
1937 found during compilation. The check is performed on the list of methods
1938 in the final stage of compilation. Additionally, a check is performed
1939 for each selector appearing in a @code{@@selector(@dots{})}
1940 expression, and a corresponding method for that selector has been found
1941 during compilation. Because these checks scan the method table only at
1942 the end of compilation, these warnings are not produced if the final
1943 stage of compilation is not reached, for example because an error is
1944 found during compilation, or because the @code{-fsyntax-only} option is
1947 @item -Wundeclared-selector
1948 @opindex Wundeclared-selector
1949 Warn if a @code{@@selector(@dots{})} expression referring to an
1950 undeclared selector is found. A selector is considered undeclared if no
1951 method with that name has been declared before the
1952 @code{@@selector(@dots{})} expression, either explicitly in an
1953 @code{@@interface} or @code{@@protocol} declaration, or implicitly in
1954 an @code{@@implementation} section. This option always performs its
1955 checks as soon as a @code{@@selector(@dots{})} expression is found,
1956 while @code{-Wselector} only performs its checks in the final stage of
1957 compilation. This also enforces the coding style convention
1958 that methods and selectors must be declared before being used.
1960 @item -print-objc-runtime-info
1961 @opindex print-objc-runtime-info
1962 Generate C header describing the largest structure that is passed by
1967 @node Language Independent Options
1968 @section Options to Control Diagnostic Messages Formatting
1969 @cindex options to control diagnostics formatting
1970 @cindex diagnostic messages
1971 @cindex message formatting
1973 Traditionally, diagnostic messages have been formatted irrespective of
1974 the output device's aspect (e.g.@: its width, @dots{}). The options described
1975 below can be used to control the diagnostic messages formatting
1976 algorithm, e.g.@: how many characters per line, how often source location
1977 information should be reported. Right now, only the C++ front end can
1978 honor these options. However it is expected, in the near future, that
1979 the remaining front ends would be able to digest them correctly.
1982 @item -fmessage-length=@var{n}
1983 @opindex fmessage-length
1984 Try to format error messages so that they fit on lines of about @var{n}
1985 characters. The default is 72 characters for @command{g++} and 0 for the rest of
1986 the front ends supported by GCC@. If @var{n} is zero, then no
1987 line-wrapping will be done; each error message will appear on a single
1990 @opindex fdiagnostics-show-location
1991 @item -fdiagnostics-show-location=once
1992 Only meaningful in line-wrapping mode. Instructs the diagnostic messages
1993 reporter to emit @emph{once} source location information; that is, in
1994 case the message is too long to fit on a single physical line and has to
1995 be wrapped, the source location won't be emitted (as prefix) again,
1996 over and over, in subsequent continuation lines. This is the default
1999 @item -fdiagnostics-show-location=every-line
2000 Only meaningful in line-wrapping mode. Instructs the diagnostic
2001 messages reporter to emit the same source location information (as
2002 prefix) for physical lines that result from the process of breaking
2003 a message which is too long to fit on a single line.
2007 @node Warning Options
2008 @section Options to Request or Suppress Warnings
2009 @cindex options to control warnings
2010 @cindex warning messages
2011 @cindex messages, warning
2012 @cindex suppressing warnings
2014 Warnings are diagnostic messages that report constructions which
2015 are not inherently erroneous but which are risky or suggest there
2016 may have been an error.
2018 You can request many specific warnings with options beginning @samp{-W},
2019 for example @option{-Wimplicit} to request warnings on implicit
2020 declarations. Each of these specific warning options also has a
2021 negative form beginning @samp{-Wno-} to turn off warnings;
2022 for example, @option{-Wno-implicit}. This manual lists only one of the
2023 two forms, whichever is not the default.
2025 The following options control the amount and kinds of warnings produced
2026 by GCC; for further, language-specific options also refer to
2027 @ref{C++ Dialect Options} and @ref{Objective-C Dialect Options}.
2030 @cindex syntax checking
2032 @opindex fsyntax-only
2033 Check the code for syntax errors, but don't do anything beyond that.
2037 Issue all the warnings demanded by strict ISO C and ISO C++;
2038 reject all programs that use forbidden extensions, and some other
2039 programs that do not follow ISO C and ISO C++. For ISO C, follows the
2040 version of the ISO C standard specified by any @option{-std} option used.
2042 Valid ISO C and ISO C++ programs should compile properly with or without
2043 this option (though a rare few will require @option{-ansi} or a
2044 @option{-std} option specifying the required version of ISO C)@. However,
2045 without this option, certain GNU extensions and traditional C and C++
2046 features are supported as well. With this option, they are rejected.
2048 @option{-pedantic} does not cause warning messages for use of the
2049 alternate keywords whose names begin and end with @samp{__}. Pedantic
2050 warnings are also disabled in the expression that follows
2051 @code{__extension__}. However, only system header files should use
2052 these escape routes; application programs should avoid them.
2053 @xref{Alternate Keywords}.
2055 Some users try to use @option{-pedantic} to check programs for strict ISO
2056 C conformance. They soon find that it does not do quite what they want:
2057 it finds some non-ISO practices, but not all---only those for which
2058 ISO C @emph{requires} a diagnostic, and some others for which
2059 diagnostics have been added.
2061 A feature to report any failure to conform to ISO C might be useful in
2062 some instances, but would require considerable additional work and would
2063 be quite different from @option{-pedantic}. We don't have plans to
2064 support such a feature in the near future.
2066 Where the standard specified with @option{-std} represents a GNU
2067 extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a
2068 corresponding @dfn{base standard}, the version of ISO C on which the GNU
2069 extended dialect is based. Warnings from @option{-pedantic} are given
2070 where they are required by the base standard. (It would not make sense
2071 for such warnings to be given only for features not in the specified GNU
2072 C dialect, since by definition the GNU dialects of C include all
2073 features the compiler supports with the given option, and there would be
2074 nothing to warn about.)
2076 @item -pedantic-errors
2077 @opindex pedantic-errors
2078 Like @option{-pedantic}, except that errors are produced rather than
2083 Inhibit all warning messages.
2087 Inhibit warning messages about the use of @samp{#import}.
2089 @item -Wchar-subscripts
2090 @opindex Wchar-subscripts
2091 Warn if an array subscript has type @code{char}. This is a common cause
2092 of error, as programmers often forget that this type is signed on some
2097 Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
2098 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
2100 @item -Wfatal-errors
2101 @opindex Wfatal-errors
2102 This option causes the compiler to abort compilation on the first error
2103 occurred rather than trying to keep going and printing further error
2108 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
2109 the arguments supplied have types appropriate to the format string
2110 specified, and that the conversions specified in the format string make
2111 sense. This includes standard functions, and others specified by format
2112 attributes (@pxref{Function Attributes}), in the @code{printf},
2113 @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension,
2114 not in the C standard) families.
2116 The formats are checked against the format features supported by GNU
2117 libc version 2.2. These include all ISO C90 and C99 features, as well
2118 as features from the Single Unix Specification and some BSD and GNU
2119 extensions. Other library implementations may not support all these
2120 features; GCC does not support warning about features that go beyond a
2121 particular library's limitations. However, if @option{-pedantic} is used
2122 with @option{-Wformat}, warnings will be given about format features not
2123 in the selected standard version (but not for @code{strfmon} formats,
2124 since those are not in any version of the C standard). @xref{C Dialect
2125 Options,,Options Controlling C Dialect}.
2127 Since @option{-Wformat} also checks for null format arguments for
2128 several functions, @option{-Wformat} also implies @option{-Wnonnull}.
2130 @option{-Wformat} is included in @option{-Wall}. For more control over some
2131 aspects of format checking, the options @option{-Wformat-y2k},
2132 @option{-Wno-format-extra-args}, @option{-Wno-format-zero-length},
2133 @option{-Wformat-nonliteral}, @option{-Wformat-security}, and
2134 @option{-Wformat=2} are available, but are not included in @option{-Wall}.
2137 @opindex Wformat-y2k
2138 If @option{-Wformat} is specified, also warn about @code{strftime}
2139 formats which may yield only a two-digit year.
2141 @item -Wno-format-extra-args
2142 @opindex Wno-format-extra-args
2143 If @option{-Wformat} is specified, do not warn about excess arguments to a
2144 @code{printf} or @code{scanf} format function. The C standard specifies
2145 that such arguments are ignored.
2147 Where the unused arguments lie between used arguments that are
2148 specified with @samp{$} operand number specifications, normally
2149 warnings are still given, since the implementation could not know what
2150 type to pass to @code{va_arg} to skip the unused arguments. However,
2151 in the case of @code{scanf} formats, this option will suppress the
2152 warning if the unused arguments are all pointers, since the Single
2153 Unix Specification says that such unused arguments are allowed.
2155 @item -Wno-format-zero-length
2156 @opindex Wno-format-zero-length
2157 If @option{-Wformat} is specified, do not warn about zero-length formats.
2158 The C standard specifies that zero-length formats are allowed.
2160 @item -Wformat-nonliteral
2161 @opindex Wformat-nonliteral
2162 If @option{-Wformat} is specified, also warn if the format string is not a
2163 string literal and so cannot be checked, unless the format function
2164 takes its format arguments as a @code{va_list}.
2166 @item -Wformat-security
2167 @opindex Wformat-security
2168 If @option{-Wformat} is specified, also warn about uses of format
2169 functions that represent possible security problems. At present, this
2170 warns about calls to @code{printf} and @code{scanf} functions where the
2171 format string is not a string literal and there are no format arguments,
2172 as in @code{printf (foo);}. This may be a security hole if the format
2173 string came from untrusted input and contains @samp{%n}. (This is
2174 currently a subset of what @option{-Wformat-nonliteral} warns about, but
2175 in future warnings may be added to @option{-Wformat-security} that are not
2176 included in @option{-Wformat-nonliteral}.)
2180 Enable @option{-Wformat} plus format checks not included in
2181 @option{-Wformat}. Currently equivalent to @samp{-Wformat
2182 -Wformat-nonliteral -Wformat-security -Wformat-y2k}.
2186 Warn about passing a null pointer for arguments marked as
2187 requiring a non-null value by the @code{nonnull} function attribute.
2189 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}. It
2190 can be disabled with the @option{-Wno-nonnull} option.
2192 @item -Winit-self @r{(C, C++, and Objective-C only)}
2194 Warn about uninitialized variables which are initialized with themselves.
2195 Note this option can only be used with the @option{-Wuninitialized} option,
2196 which in turn only works with @option{-O1} and above.
2198 For example, GCC will warn about @code{i} being uninitialized in the
2199 following snippet only when @option{-Winit-self} has been specified:
2210 @item -Wimplicit-int
2211 @opindex Wimplicit-int
2212 Warn when a declaration does not specify a type.
2214 @item -Wimplicit-function-declaration
2215 @itemx -Werror-implicit-function-declaration
2216 @opindex Wimplicit-function-declaration
2217 @opindex Werror-implicit-function-declaration
2218 Give a warning (or error) whenever a function is used before being
2223 Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}.
2227 Warn if the type of @samp{main} is suspicious. @samp{main} should be a
2228 function with external linkage, returning int, taking either zero
2229 arguments, two, or three arguments of appropriate types.
2231 @item -Wmissing-braces
2232 @opindex Wmissing-braces
2233 Warn if an aggregate or union initializer is not fully bracketed. In
2234 the following example, the initializer for @samp{a} is not fully
2235 bracketed, but that for @samp{b} is fully bracketed.
2238 int a[2][2] = @{ 0, 1, 2, 3 @};
2239 int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @};
2242 @item -Wmissing-include-dirs @r{(C, C++, and Objective-C only)}
2243 @opindex Wmissing-include-dirs
2244 Warn if a user-supplied include directory does not exist.
2247 @opindex Wparentheses
2248 Warn if parentheses are omitted in certain contexts, such
2249 as when there is an assignment in a context where a truth value
2250 is expected, or when operators are nested whose precedence people
2251 often get confused about.
2253 Also warn about constructions where there may be confusion to which
2254 @code{if} statement an @code{else} branch belongs. Here is an example of
2269 In C, every @code{else} branch belongs to the innermost possible @code{if}
2270 statement, which in this example is @code{if (b)}. This is often not
2271 what the programmer expected, as illustrated in the above example by
2272 indentation the programmer chose. When there is the potential for this
2273 confusion, GCC will issue a warning when this flag is specified.
2274 To eliminate the warning, add explicit braces around the innermost
2275 @code{if} statement so there is no way the @code{else} could belong to
2276 the enclosing @code{if}. The resulting code would look like this:
2292 @item -Wsequence-point
2293 @opindex Wsequence-point
2294 Warn about code that may have undefined semantics because of violations
2295 of sequence point rules in the C standard.
2297 The C standard defines the order in which expressions in a C program are
2298 evaluated in terms of @dfn{sequence points}, which represent a partial
2299 ordering between the execution of parts of the program: those executed
2300 before the sequence point, and those executed after it. These occur
2301 after the evaluation of a full expression (one which is not part of a
2302 larger expression), after the evaluation of the first operand of a
2303 @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
2304 function is called (but after the evaluation of its arguments and the
2305 expression denoting the called function), and in certain other places.
2306 Other than as expressed by the sequence point rules, the order of
2307 evaluation of subexpressions of an expression is not specified. All
2308 these rules describe only a partial order rather than a total order,
2309 since, for example, if two functions are called within one expression
2310 with no sequence point between them, the order in which the functions
2311 are called is not specified. However, the standards committee have
2312 ruled that function calls do not overlap.
2314 It is not specified when between sequence points modifications to the
2315 values of objects take effect. Programs whose behavior depends on this
2316 have undefined behavior; the C standard specifies that ``Between the
2317 previous and next sequence point an object shall have its stored value
2318 modified at most once by the evaluation of an expression. Furthermore,
2319 the prior value shall be read only to determine the value to be
2320 stored.''. If a program breaks these rules, the results on any
2321 particular implementation are entirely unpredictable.
2323 Examples of code with undefined behavior are @code{a = a++;}, @code{a[n]
2324 = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not
2325 diagnosed by this option, and it may give an occasional false positive
2326 result, but in general it has been found fairly effective at detecting
2327 this sort of problem in programs.
2329 The present implementation of this option only works for C programs. A
2330 future implementation may also work for C++ programs.
2332 The C standard is worded confusingly, therefore there is some debate
2333 over the precise meaning of the sequence point rules in subtle cases.
2334 Links to discussions of the problem, including proposed formal
2335 definitions, may be found on our readings page, at
2336 @w{@uref{http://gcc.gnu.org/readings.html}}.
2339 @opindex Wreturn-type
2340 Warn whenever a function is defined with a return-type that defaults to
2341 @code{int}. Also warn about any @code{return} statement with no
2342 return-value in a function whose return-type is not @code{void}.
2344 For C++, a function without return type always produces a diagnostic
2345 message, even when @option{-Wno-return-type} is specified. The only
2346 exceptions are @samp{main} and functions defined in system headers.
2350 Warn whenever a @code{switch} statement has an index of enumeral type
2351 and lacks a @code{case} for one or more of the named codes of that
2352 enumeration. (The presence of a @code{default} label prevents this
2353 warning.) @code{case} labels outside the enumeration range also
2354 provoke warnings when this option is used.
2356 @item -Wswitch-default
2357 @opindex Wswitch-switch
2358 Warn whenever a @code{switch} statement does not have a @code{default}
2362 @opindex Wswitch-enum
2363 Warn whenever a @code{switch} statement has an index of enumeral type
2364 and lacks a @code{case} for one or more of the named codes of that
2365 enumeration. @code{case} labels outside the enumeration range also
2366 provoke warnings when this option is used.
2370 Warn if any trigraphs are encountered that might change the meaning of
2371 the program (trigraphs within comments are not warned about).
2373 @item -Wunused-function
2374 @opindex Wunused-function
2375 Warn whenever a static function is declared but not defined or a
2376 non\-inline static function is unused.
2378 @item -Wunused-label
2379 @opindex Wunused-label
2380 Warn whenever a label is declared but not used.
2382 To suppress this warning use the @samp{unused} attribute
2383 (@pxref{Variable Attributes}).
2385 @item -Wunused-parameter
2386 @opindex Wunused-parameter
2387 Warn whenever a function parameter is unused aside from its declaration.
2389 To suppress this warning use the @samp{unused} attribute
2390 (@pxref{Variable Attributes}).
2392 @item -Wunused-variable
2393 @opindex Wunused-variable
2394 Warn whenever a local variable or non-constant static variable is unused
2395 aside from its declaration
2397 To suppress this warning use the @samp{unused} attribute
2398 (@pxref{Variable Attributes}).
2400 @item -Wunused-value
2401 @opindex Wunused-value
2402 Warn whenever a statement computes a result that is explicitly not used.
2404 To suppress this warning cast the expression to @samp{void}.
2408 All the above @option{-Wunused} options combined.
2410 In order to get a warning about an unused function parameter, you must
2411 either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
2412 @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
2414 @item -Wuninitialized
2415 @opindex Wuninitialized
2416 Warn if an automatic variable is used without first being initialized or
2417 if a variable may be clobbered by a @code{setjmp} call.
2419 These warnings are possible only in optimizing compilation,
2420 because they require data flow information that is computed only
2421 when optimizing. If you don't specify @option{-O}, you simply won't
2424 If you want to warn about code which uses the uninitialized value of the
2425 variable in its own initializer, use the @option{-Winit-self} option.
2427 These warnings occur only for variables that are candidates for
2428 register allocation. Therefore, they do not occur for a variable that
2429 is declared @code{volatile}, or whose address is taken, or whose size
2430 is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
2431 structures, unions or arrays, even when they are in registers.
2433 Note that there may be no warning about a variable that is used only
2434 to compute a value that itself is never used, because such
2435 computations may be deleted by data flow analysis before the warnings
2438 These warnings are made optional because GCC is not smart
2439 enough to see all the reasons why the code might be correct
2440 despite appearing to have an error. Here is one example of how
2461 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
2462 always initialized, but GCC doesn't know this. Here is
2463 another common case:
2468 if (change_y) save_y = y, y = new_y;
2470 if (change_y) y = save_y;
2475 This has no bug because @code{save_y} is used only if it is set.
2477 @cindex @code{longjmp} warnings
2478 This option also warns when a non-volatile automatic variable might be
2479 changed by a call to @code{longjmp}. These warnings as well are possible
2480 only in optimizing compilation.
2482 The compiler sees only the calls to @code{setjmp}. It cannot know
2483 where @code{longjmp} will be called; in fact, a signal handler could
2484 call it at any point in the code. As a result, you may get a warning
2485 even when there is in fact no problem because @code{longjmp} cannot
2486 in fact be called at the place which would cause a problem.
2488 Some spurious warnings can be avoided if you declare all the functions
2489 you use that never return as @code{noreturn}. @xref{Function
2492 @item -Wunknown-pragmas
2493 @opindex Wunknown-pragmas
2494 @cindex warning for unknown pragmas
2495 @cindex unknown pragmas, warning
2496 @cindex pragmas, warning of unknown
2497 Warn when a #pragma directive is encountered which is not understood by
2498 GCC@. If this command line option is used, warnings will even be issued
2499 for unknown pragmas in system header files. This is not the case if
2500 the warnings were only enabled by the @option{-Wall} command line option.
2502 @item -Wstrict-aliasing
2503 @opindex Wstrict-aliasing
2504 This option is only active when @option{-fstrict-aliasing} is active.
2505 It warns about code which might break the strict aliasing rules that the
2506 compiler is using for optimization. The warning does not catch all
2507 cases, but does attempt to catch the more common pitfalls. It is
2508 included in @option{-Wall}.
2510 @item -Wstrict-aliasing=2
2511 @opindex Wstrict-aliasing=2
2512 This option is only active when @option{-fstrict-aliasing} is active.
2513 It warns about all code which might break the strict aliasing rules that the
2514 compiler is using for optimization. This warning catches all cases, but
2515 it will also give a warning for some ambiguous cases that are safe.
2519 All of the above @samp{-W} options combined. This enables all the
2520 warnings about constructions that some users consider questionable, and
2521 that are easy to avoid (or modify to prevent the warning), even in
2522 conjunction with macros. This also enables some language-specific
2523 warnings described in @ref{C++ Dialect Options} and
2524 @ref{Objective-C Dialect Options}.
2527 The following @option{-W@dots{}} options are not implied by @option{-Wall}.
2528 Some of them warn about constructions that users generally do not
2529 consider questionable, but which occasionally you might wish to check
2530 for; others warn about constructions that are necessary or hard to avoid
2531 in some cases, and there is no simple way to modify the code to suppress
2538 (This option used to be called @option{-W}. The older name is still
2539 supported, but the newer name is more descriptive.) Print extra warning
2540 messages for these events:
2544 A function can return either with or without a value. (Falling
2545 off the end of the function body is considered returning without
2546 a value.) For example, this function would evoke such a
2560 An expression-statement or the left-hand side of a comma expression
2561 contains no side effects.
2562 To suppress the warning, cast the unused expression to void.
2563 For example, an expression such as @samp{x[i,j]} will cause a warning,
2564 but @samp{x[(void)i,j]} will not.
2567 An unsigned value is compared against zero with @samp{<} or @samp{>=}.
2570 A comparison like @samp{x<=y<=z} appears; this is equivalent to
2571 @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
2572 that of ordinary mathematical notation.
2575 Storage-class specifiers like @code{static} are not the first things in
2576 a declaration. According to the C Standard, this usage is obsolescent.
2579 The return type of a function has a type qualifier such as @code{const}.
2580 Such a type qualifier has no effect, since the value returned by a
2581 function is not an lvalue. (But don't warn about the GNU extension of
2582 @code{volatile void} return types. That extension will be warned about
2583 if @option{-pedantic} is specified.)
2586 If @option{-Wall} or @option{-Wunused} is also specified, warn about unused
2590 A comparison between signed and unsigned values could produce an
2591 incorrect result when the signed value is converted to unsigned.
2592 (But don't warn if @option{-Wno-sign-compare} is also specified.)
2595 An aggregate has an initializer which does not initialize all members.
2596 For example, the following code would cause such a warning, because
2597 @code{x.h} would be implicitly initialized to zero:
2600 struct s @{ int f, g, h; @};
2601 struct s x = @{ 3, 4 @};
2605 A function parameter is declared without a type specifier in K&R-style
2613 An empty body occurs in an @samp{if} or @samp{else} statement.
2616 A pointer is compared against integer zero with @samp{<}, @samp{<=},
2617 @samp{>}, or @samp{>=}.
2620 A variable might be changed by @samp{longjmp} or @samp{vfork}.
2623 Any of several floating-point events that often indicate errors, such as
2624 overflow, underflow, loss of precision, etc.
2626 @item @r{(C++ only)}
2627 An enumerator and a non-enumerator both appear in a conditional expression.
2629 @item @r{(C++ only)}
2630 A non-static reference or non-static @samp{const} member appears in a
2631 class without constructors.
2633 @item @r{(C++ only)}
2634 Ambiguous virtual bases.
2636 @item @r{(C++ only)}
2637 Subscripting an array which has been declared @samp{register}.
2639 @item @r{(C++ only)}
2640 Taking the address of a variable which has been declared @samp{register}.
2642 @item @r{(C++ only)}
2643 A base class is not initialized in a derived class' copy constructor.
2646 @item -Wno-div-by-zero
2647 @opindex Wno-div-by-zero
2648 @opindex Wdiv-by-zero
2649 Do not warn about compile-time integer division by zero. Floating point
2650 division by zero is not warned about, as it can be a legitimate way of
2651 obtaining infinities and NaNs.
2653 @item -Wsystem-headers
2654 @opindex Wsystem-headers
2655 @cindex warnings from system headers
2656 @cindex system headers, warnings from
2657 Print warning messages for constructs found in system header files.
2658 Warnings from system headers are normally suppressed, on the assumption
2659 that they usually do not indicate real problems and would only make the
2660 compiler output harder to read. Using this command line option tells
2661 GCC to emit warnings from system headers as if they occurred in user
2662 code. However, note that using @option{-Wall} in conjunction with this
2663 option will @emph{not} warn about unknown pragmas in system
2664 headers---for that, @option{-Wunknown-pragmas} must also be used.
2667 @opindex Wfloat-equal
2668 Warn if floating point values are used in equality comparisons.
2670 The idea behind this is that sometimes it is convenient (for the
2671 programmer) to consider floating-point values as approximations to
2672 infinitely precise real numbers. If you are doing this, then you need
2673 to compute (by analyzing the code, or in some other way) the maximum or
2674 likely maximum error that the computation introduces, and allow for it
2675 when performing comparisons (and when producing output, but that's a
2676 different problem). In particular, instead of testing for equality, you
2677 would check to see whether the two values have ranges that overlap; and
2678 this is done with the relational operators, so equality comparisons are
2681 @item -Wtraditional @r{(C only)}
2682 @opindex Wtraditional
2683 Warn about certain constructs that behave differently in traditional and
2684 ISO C@. Also warn about ISO C constructs that have no traditional C
2685 equivalent, and/or problematic constructs which should be avoided.
2689 Macro parameters that appear within string literals in the macro body.
2690 In traditional C macro replacement takes place within string literals,
2691 but does not in ISO C@.
2694 In traditional C, some preprocessor directives did not exist.
2695 Traditional preprocessors would only consider a line to be a directive
2696 if the @samp{#} appeared in column 1 on the line. Therefore
2697 @option{-Wtraditional} warns about directives that traditional C
2698 understands but would ignore because the @samp{#} does not appear as the
2699 first character on the line. It also suggests you hide directives like
2700 @samp{#pragma} not understood by traditional C by indenting them. Some
2701 traditional implementations would not recognize @samp{#elif}, so it
2702 suggests avoiding it altogether.
2705 A function-like macro that appears without arguments.
2708 The unary plus operator.
2711 The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point
2712 constant suffixes. (Traditional C does support the @samp{L} suffix on integer
2713 constants.) Note, these suffixes appear in macros defined in the system
2714 headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}.
2715 Use of these macros in user code might normally lead to spurious
2716 warnings, however GCC's integrated preprocessor has enough context to
2717 avoid warning in these cases.
2720 A function declared external in one block and then used after the end of
2724 A @code{switch} statement has an operand of type @code{long}.
2727 A non-@code{static} function declaration follows a @code{static} one.
2728 This construct is not accepted by some traditional C compilers.
2731 The ISO type of an integer constant has a different width or
2732 signedness from its traditional type. This warning is only issued if
2733 the base of the constant is ten. I.e.@: hexadecimal or octal values, which
2734 typically represent bit patterns, are not warned about.
2737 Usage of ISO string concatenation is detected.
2740 Initialization of automatic aggregates.
2743 Identifier conflicts with labels. Traditional C lacks a separate
2744 namespace for labels.
2747 Initialization of unions. If the initializer is zero, the warning is
2748 omitted. This is done under the assumption that the zero initializer in
2749 user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing
2750 initializer warnings and relies on default initialization to zero in the
2754 Conversions by prototypes between fixed/floating point values and vice
2755 versa. The absence of these prototypes when compiling with traditional
2756 C would cause serious problems. This is a subset of the possible
2757 conversion warnings, for the full set use @option{-Wconversion}.
2760 Use of ISO C style function definitions. This warning intentionally is
2761 @emph{not} issued for prototype declarations or variadic functions
2762 because these ISO C features will appear in your code when using
2763 libiberty's traditional C compatibility macros, @code{PARAMS} and
2764 @code{VPARAMS}. This warning is also bypassed for nested functions
2765 because that feature is already a GCC extension and thus not relevant to
2766 traditional C compatibility.
2769 @item -Wdeclaration-after-statement @r{(C only)}
2770 @opindex Wdeclaration-after-statement
2771 Warn when a declaration is found after a statement in a block. This
2772 construct, known from C++, was introduced with ISO C99 and is by default
2773 allowed in GCC@. It is not supported by ISO C90 and was not supported by
2774 GCC versions before GCC 3.0. @xref{Mixed Declarations}.
2778 Warn if an undefined identifier is evaluated in an @samp{#if} directive.
2780 @item -Wendif-labels
2781 @opindex Wendif-labels
2782 Warn whenever an @samp{#else} or an @samp{#endif} are followed by text.
2786 Warn whenever a local variable shadows another local variable, parameter or
2787 global variable or whenever a built-in function is shadowed.
2789 @item -Wlarger-than-@var{len}
2790 @opindex Wlarger-than
2791 Warn whenever an object of larger than @var{len} bytes is defined.
2793 @item -Wpointer-arith
2794 @opindex Wpointer-arith
2795 Warn about anything that depends on the ``size of'' a function type or
2796 of @code{void}. GNU C assigns these types a size of 1, for
2797 convenience in calculations with @code{void *} pointers and pointers
2800 @item -Wbad-function-cast @r{(C only)}
2801 @opindex Wbad-function-cast
2802 Warn whenever a function call is cast to a non-matching type.
2803 For example, warn if @code{int malloc()} is cast to @code{anything *}.
2807 Warn whenever a pointer is cast so as to remove a type qualifier from
2808 the target type. For example, warn if a @code{const char *} is cast
2809 to an ordinary @code{char *}.
2812 @opindex Wcast-align
2813 Warn whenever a pointer is cast such that the required alignment of the
2814 target is increased. For example, warn if a @code{char *} is cast to
2815 an @code{int *} on machines where integers can only be accessed at
2816 two- or four-byte boundaries.
2818 @item -Wwrite-strings
2819 @opindex Wwrite-strings
2820 When compiling C, give string constants the type @code{const
2821 char[@var{length}]} so that
2822 copying the address of one into a non-@code{const} @code{char *}
2823 pointer will get a warning; when compiling C++, warn about the
2824 deprecated conversion from string constants to @code{char *}.
2825 These warnings will help you find at
2826 compile time code that can try to write into a string constant, but
2827 only if you have been very careful about using @code{const} in
2828 declarations and prototypes. Otherwise, it will just be a nuisance;
2829 this is why we did not make @option{-Wall} request these warnings.
2832 @opindex Wconversion
2833 Warn if a prototype causes a type conversion that is different from what
2834 would happen to the same argument in the absence of a prototype. This
2835 includes conversions of fixed point to floating and vice versa, and
2836 conversions changing the width or signedness of a fixed point argument
2837 except when the same as the default promotion.
2839 Also, warn if a negative integer constant expression is implicitly
2840 converted to an unsigned type. For example, warn about the assignment
2841 @code{x = -1} if @code{x} is unsigned. But do not warn about explicit
2842 casts like @code{(unsigned) -1}.
2844 @item -Wsign-compare
2845 @opindex Wsign-compare
2846 @cindex warning for comparison of signed and unsigned values
2847 @cindex comparison of signed and unsigned values, warning
2848 @cindex signed and unsigned values, comparison warning
2849 Warn when a comparison between signed and unsigned values could produce
2850 an incorrect result when the signed value is converted to unsigned.
2851 This warning is also enabled by @option{-Wextra}; to get the other warnings
2852 of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
2854 @item -Waggregate-return
2855 @opindex Waggregate-return
2856 Warn if any functions that return structures or unions are defined or
2857 called. (In languages where you can return an array, this also elicits
2860 @item -Wstrict-prototypes @r{(C only)}
2861 @opindex Wstrict-prototypes
2862 Warn if a function is declared or defined without specifying the
2863 argument types. (An old-style function definition is permitted without
2864 a warning if preceded by a declaration which specifies the argument
2867 @item -Wold-style-definition @r{(C only)}
2868 @opindex Wold-style-definition
2869 Warn if an old-style function definition is used. A warning is given
2870 even if there is a previous prototype.
2872 @item -Wmissing-prototypes @r{(C only)}
2873 @opindex Wmissing-prototypes
2874 Warn if a global function is defined without a previous prototype
2875 declaration. This warning is issued even if the definition itself
2876 provides a prototype. The aim is to detect global functions that fail
2877 to be declared in header files.
2879 @item -Wmissing-declarations @r{(C only)}
2880 @opindex Wmissing-declarations
2881 Warn if a global function is defined without a previous declaration.
2882 Do so even if the definition itself provides a prototype.
2883 Use this option to detect global functions that are not declared in
2886 @item -Wmissing-noreturn
2887 @opindex Wmissing-noreturn
2888 Warn about functions which might be candidates for attribute @code{noreturn}.
2889 Note these are only possible candidates, not absolute ones. Care should
2890 be taken to manually verify functions actually do not ever return before
2891 adding the @code{noreturn} attribute, otherwise subtle code generation
2892 bugs could be introduced. You will not get a warning for @code{main} in
2893 hosted C environments.
2895 @item -Wmissing-format-attribute
2896 @opindex Wmissing-format-attribute
2898 If @option{-Wformat} is enabled, also warn about functions which might be
2899 candidates for @code{format} attributes. Note these are only possible
2900 candidates, not absolute ones. GCC will guess that @code{format}
2901 attributes might be appropriate for any function that calls a function
2902 like @code{vprintf} or @code{vscanf}, but this might not always be the
2903 case, and some functions for which @code{format} attributes are
2904 appropriate may not be detected. This option has no effect unless
2905 @option{-Wformat} is enabled (possibly by @option{-Wall}).
2907 @item -Wno-multichar
2908 @opindex Wno-multichar
2910 Do not warn if a multicharacter constant (@samp{'FOOF'}) is used.
2911 Usually they indicate a typo in the user's code, as they have
2912 implementation-defined values, and should not be used in portable code.
2914 @item -Wno-deprecated-declarations
2915 @opindex Wno-deprecated-declarations
2916 Do not warn about uses of functions, variables, and types marked as
2917 deprecated by using the @code{deprecated} attribute.
2918 (@pxref{Function Attributes}, @pxref{Variable Attributes},
2919 @pxref{Type Attributes}.)
2923 Warn if a structure is given the packed attribute, but the packed
2924 attribute has no effect on the layout or size of the structure.
2925 Such structures may be mis-aligned for little benefit. For
2926 instance, in this code, the variable @code{f.x} in @code{struct bar}
2927 will be misaligned even though @code{struct bar} does not itself
2928 have the packed attribute:
2935 @} __attribute__((packed));
2945 Warn if padding is included in a structure, either to align an element
2946 of the structure or to align the whole structure. Sometimes when this
2947 happens it is possible to rearrange the fields of the structure to
2948 reduce the padding and so make the structure smaller.
2950 @item -Wredundant-decls
2951 @opindex Wredundant-decls
2952 Warn if anything is declared more than once in the same scope, even in
2953 cases where multiple declaration is valid and changes nothing.
2955 @item -Wnested-externs @r{(C only)}
2956 @opindex Wnested-externs
2957 Warn if an @code{extern} declaration is encountered within a function.
2959 @item -Wunreachable-code
2960 @opindex Wunreachable-code
2961 Warn if the compiler detects that code will never be executed.
2963 This option is intended to warn when the compiler detects that at
2964 least a whole line of source code will never be executed, because
2965 some condition is never satisfied or because it is after a
2966 procedure that never returns.
2968 It is possible for this option to produce a warning even though there
2969 are circumstances under which part of the affected line can be executed,
2970 so care should be taken when removing apparently-unreachable code.
2972 For instance, when a function is inlined, a warning may mean that the
2973 line is unreachable in only one inlined copy of the function.
2975 This option is not made part of @option{-Wall} because in a debugging
2976 version of a program there is often substantial code which checks
2977 correct functioning of the program and is, hopefully, unreachable
2978 because the program does work. Another common use of unreachable
2979 code is to provide behavior which is selectable at compile-time.
2983 Warn if a function can not be inlined and it was declared as inline.
2984 Even with this option, the compiler will not warn about failures to
2985 inline functions declared in system headers.
2987 The compiler uses a variety of heuristics to determine whether or not
2988 to inline a function. For example, the compiler takes into account
2989 the size of the function being inlined and the the amount of inlining
2990 that has already been done in the current function. Therefore,
2991 seemingly insignificant changes in the source program can cause the
2992 warnings produced by @option{-Winline} to appear or disappear.
2994 @item -Wno-invalid-offsetof @r{(C++ only)}
2995 @opindex Wno-invalid-offsetof
2996 Suppress warnings from applying the @samp{offsetof} macro to a non-POD
2997 type. According to the 1998 ISO C++ standard, applying @samp{offsetof}
2998 to a non-POD type is undefined. In existing C++ implementations,
2999 however, @samp{offsetof} typically gives meaningful results even when
3000 applied to certain kinds of non-POD types. (Such as a simple
3001 @samp{struct} that fails to be a POD type only by virtue of having a
3002 constructor.) This flag is for users who are aware that they are
3003 writing nonportable code and who have deliberately chosen to ignore the
3006 The restrictions on @samp{offsetof} may be relaxed in a future version
3007 of the C++ standard.
3010 @opindex Winvalid-pch
3011 Warn if a precompiled header (@pxref{Precompiled Headers}) is found in
3012 the search path but can't be used.
3016 @opindex Wno-long-long
3017 Warn if @samp{long long} type is used. This is default. To inhibit
3018 the warning messages, use @option{-Wno-long-long}. Flags
3019 @option{-Wlong-long} and @option{-Wno-long-long} are taken into account
3020 only when @option{-pedantic} flag is used.
3022 @item -Wvariadic-macros
3023 @opindex Wvariadic-macros
3024 @opindex Wno-variadic-macros
3025 Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
3026 alternate syntax when in pedantic ISO C99 mode. This is default.
3027 To inhibit the warning messages, use @option{-Wno-variadic-macros}.
3029 @item -Wdisabled-optimization
3030 @opindex Wdisabled-optimization
3031 Warn if a requested optimization pass is disabled. This warning does
3032 not generally indicate that there is anything wrong with your code; it
3033 merely indicates that GCC's optimizers were unable to handle the code
3034 effectively. Often, the problem is that your code is too big or too
3035 complex; GCC will refuse to optimize programs when the optimization
3036 itself is likely to take inordinate amounts of time.
3040 Make all warnings into errors.
3043 @node Debugging Options
3044 @section Options for Debugging Your Program or GCC
3045 @cindex options, debugging
3046 @cindex debugging information options
3048 GCC has various special options that are used for debugging
3049 either your program or GCC:
3054 Produce debugging information in the operating system's native format
3055 (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging
3058 On most systems that use stabs format, @option{-g} enables use of extra
3059 debugging information that only GDB can use; this extra information
3060 makes debugging work better in GDB but will probably make other debuggers
3062 refuse to read the program. If you want to control for certain whether
3063 to generate the extra information, use @option{-gstabs+}, @option{-gstabs},
3064 @option{-gxcoff+}, @option{-gxcoff}, or @option{-gvms} (see below).
3066 Unlike most other C compilers, GCC allows you to use @option{-g} with
3067 @option{-O}. The shortcuts taken by optimized code may occasionally
3068 produce surprising results: some variables you declared may not exist
3069 at all; flow of control may briefly move where you did not expect it;
3070 some statements may not be executed because they compute constant
3071 results or their values were already at hand; some statements may
3072 execute in different places because they were moved out of loops.
3074 Nevertheless it proves possible to debug optimized output. This makes
3075 it reasonable to use the optimizer for programs that might have bugs.
3077 The following options are useful when GCC is generated with the
3078 capability for more than one debugging format.
3082 Produce debugging information for use by GDB@. This means to use the
3083 most expressive format available (DWARF 2, stabs, or the native format
3084 if neither of those are supported), including GDB extensions if at all
3089 Produce debugging information in stabs format (if that is supported),
3090 without GDB extensions. This is the format used by DBX on most BSD
3091 systems. On MIPS, Alpha and System V Release 4 systems this option
3092 produces stabs debugging output which is not understood by DBX or SDB@.
3093 On System V Release 4 systems this option requires the GNU assembler.
3095 @item -feliminate-unused-debug-symbols
3096 @opindex feliminate-unused-debug-symbols
3097 Produce debugging information in stabs format (if that is supported),
3098 for only symbols that are actually used.
3102 Produce debugging information in stabs format (if that is supported),
3103 using GNU extensions understood only by the GNU debugger (GDB)@. The
3104 use of these extensions is likely to make other debuggers crash or
3105 refuse to read the program.
3109 Produce debugging information in COFF format (if that is supported).
3110 This is the format used by SDB on most System V systems prior to
3115 Produce debugging information in XCOFF format (if that is supported).
3116 This is the format used by the DBX debugger on IBM RS/6000 systems.
3120 Produce debugging information in XCOFF format (if that is supported),
3121 using GNU extensions understood only by the GNU debugger (GDB)@. The
3122 use of these extensions is likely to make other debuggers crash or
3123 refuse to read the program, and may cause assemblers other than the GNU
3124 assembler (GAS) to fail with an error.
3128 Produce debugging information in DWARF version 2 format (if that is
3129 supported). This is the format used by DBX on IRIX 6.
3133 Produce debugging information in VMS debug format (if that is
3134 supported). This is the format used by DEBUG on VMS systems.
3137 @itemx -ggdb@var{level}
3138 @itemx -gstabs@var{level}
3139 @itemx -gcoff@var{level}
3140 @itemx -gxcoff@var{level}
3141 @itemx -gvms@var{level}
3142 Request debugging information and also use @var{level} to specify how
3143 much information. The default level is 2.
3145 Level 1 produces minimal information, enough for making backtraces in
3146 parts of the program that you don't plan to debug. This includes
3147 descriptions of functions and external variables, but no information
3148 about local variables and no line numbers.
3150 Level 3 includes extra information, such as all the macro definitions
3151 present in the program. Some debuggers support macro expansion when
3152 you use @option{-g3}.
3154 Note that in order to avoid confusion between DWARF1 debug level 2,
3155 and DWARF2 @option{-gdwarf-2} does not accept a concatenated debug
3156 level. Instead use an additional @option{-g@var{level}} option to
3157 change the debug level for DWARF2.
3159 @item -feliminate-dwarf2-dups
3160 @opindex feliminate-dwarf2-dups
3161 Compress DWARF2 debugging information by eliminating duplicated
3162 information about each symbol. This option only makes sense when
3163 generating DWARF2 debugging information with @option{-gdwarf-2}.
3165 @cindex @command{prof}
3168 Generate extra code to write profile information suitable for the
3169 analysis program @command{prof}. You must use this option when compiling
3170 the source files you want data about, and you must also use it when
3173 @cindex @command{gprof}
3176 Generate extra code to write profile information suitable for the
3177 analysis program @command{gprof}. You must use this option when compiling
3178 the source files you want data about, and you must also use it when
3183 Makes the compiler print out each function name as it is compiled, and
3184 print some statistics about each pass when it finishes.
3187 @opindex ftime-report
3188 Makes the compiler print some statistics about the time consumed by each
3189 pass when it finishes.
3192 @opindex fmem-report
3193 Makes the compiler print some statistics about permanent memory
3194 allocation when it finishes.
3196 @item -fprofile-arcs
3197 @opindex fprofile-arcs
3198 Add code so that program flow @dfn{arcs} are instrumented. During
3199 execution the program records how many times each branch and call is
3200 executed and how many times it is taken or returns. When the compiled
3201 program exits it saves this data to a file called
3202 @file{@var{auxname}.gcda} for each source file. The data may be used for
3203 profile-directed optimizations (@option{-fbranch-probabilities}), or for
3204 test coverage analysis (@option{-ftest-coverage}). Each object file's
3205 @var{auxname} is generated from the name of the output file, if
3206 explicitly specified and it is not the final executable, otherwise it is
3207 the basename of the source file. In both cases any suffix is removed
3208 (e.g. @file{foo.gcda} for input file @file{dir/foo.c}, or
3209 @file{dir/foo.gcda} for output file specified as @option{-o dir/foo.o}).
3214 Compile the source files with @option{-fprofile-arcs} plus optimization
3215 and code generation options. For test coverage analysis, use the
3216 additional @option{-ftest-coverage} option. You do not need to profile
3217 every source file in a program.
3220 Link your object files with @option{-lgcov} or @option{-fprofile-arcs}
3221 (the latter implies the former).
3224 Run the program on a representative workload to generate the arc profile
3225 information. This may be repeated any number of times. You can run
3226 concurrent instances of your program, and provided that the file system
3227 supports locking, the data files will be correctly updated. Also
3228 @code{fork} calls are detected and correctly handled (double counting
3232 For profile-directed optimizations, compile the source files again with
3233 the same optimization and code generation options plus
3234 @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that
3235 Control Optimization}).
3238 For test coverage analysis, use @command{gcov} to produce human readable
3239 information from the @file{.gcno} and @file{.gcda} files. Refer to the
3240 @command{gcov} documentation for further information.
3244 With @option{-fprofile-arcs}, for each function of your program GCC
3245 creates a program flow graph, then finds a spanning tree for the graph.
3246 Only arcs that are not on the spanning tree have to be instrumented: the
3247 compiler adds code to count the number of times that these arcs are
3248 executed. When an arc is the only exit or only entrance to a block, the
3249 instrumentation code can be added to the block; otherwise, a new basic
3250 block must be created to hold the instrumentation code.
3252 @item -ftree-based-profiling
3253 @opindex ftree-based-profiling
3254 This option is used in addition to @option{-fprofile-arcs} or
3255 @option{-fbranch-probabilities} to control whether those optimizations
3256 are performed on a tree-based or rtl-based internal representation.
3257 If you use this option when compiling with @option{-fprofile-arcs},
3258 you must also use it when compiling later with @option{-fbranch-probabilities}.
3259 Currently the tree-based optimization is in an early stage of
3260 development, and this option is recommended only for those people
3261 working on improving it.
3264 @item -ftest-coverage
3265 @opindex ftest-coverage
3266 Produce a notes file that the @command{gcov} code-coverage utility
3267 (@pxref{Gcov,, @command{gcov}---a Test Coverage Program}) can use to
3268 show program coverage. Each source file's note file is called
3269 @file{@var{auxname}.gcno}. Refer to the @option{-fprofile-arcs} option
3270 above for a description of @var{auxname} and instructions on how to
3271 generate test coverage data. Coverage data will match the source files
3272 more closely, if you do not optimize.
3274 @item -d@var{letters}
3276 Says to make debugging dumps during compilation at times specified by
3277 @var{letters}. This is used for debugging the compiler. The file names
3278 for most of the dumps are made by appending a pass number and a word to
3279 the @var{dumpname}. @var{dumpname} is generated from the name of the
3280 output file, if explicitly specified and it is not an executable,
3281 otherwise it is the basename of the source file. In both cases any
3282 suffix is removed (e.g. @file{foo.01.rtl} or @file{foo.02.sibling}).
3283 Here are the possible letters for use in @var{letters}, and their
3289 Annotate the assembler output with miscellaneous debugging information.
3292 Dump after computing branch probabilities, to @file{@var{file}.12.bp}.
3295 Dump after block reordering, to @file{@var{file}.32.bbro}.
3298 Dump after instruction combination, to the file @file{@var{file}.20.combine}.
3301 Dump after the first if conversion, to the file @file{@var{file}.14.ce1}.
3302 Also dump after the second if conversion, to the file @file{@var{file}.21.ce2}.
3305 Dump after branch target load optimization, to to @file{@var{file}.33.btl}.
3306 Also dump after delayed branch scheduling, to @file{@var{file}.37.dbr}.
3309 Dump all macro definitions, at the end of preprocessing, in addition to
3313 Dump after the third if conversion, to @file{@var{file}.31.ce3}.
3316 Dump after control and data flow analysis, to @file{@var{file}.11.cfg}.
3317 Also dump after life analysis, to @file{@var{file}.19.life}.
3320 Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.07.addressof}.
3323 Dump after global register allocation, to @file{@var{file}.26.greg}.
3326 Dump after GCSE, to @file{@var{file}.08.gcse}.
3327 Also dump after jump bypassing and control flow optimizations, to
3328 @file{@var{file}.10.bypass}.
3331 Dump after finalization of EH handling code, to @file{@var{file}.03.eh}.
3334 Dump after sibling call optimizations, to @file{@var{file}.02.sibling}.
3337 Dump after the first jump optimization, to @file{@var{file}.04.jump}.
3340 Dump after conversion from registers to stack, to @file{@var{file}.35.stack}.
3343 Dump after local register allocation, to @file{@var{file}.25.lreg}.
3346 Dump after loop optimization passes, to @file{@var{file}.09.loop} and
3347 @file{@var{file}.16.loop2}.
3350 Dump after modulo scheduling, to @file{@var{file}.23.sms}.
3353 Dump after performing the machine dependent reorganization pass, to
3354 @file{@var{file}.36.mach}.
3357 Dump after register renumbering, to @file{@var{file}.30.rnreg}.
3360 Dump after the register move pass, to @file{@var{file}.22.regmove}.
3363 Dump after post-reload optimizations, to @file{@var{file}.27.postreload}.
3366 Dump after RTL generation, to @file{@var{file}.01.rtl}.
3369 Dump after the second scheduling pass, to @file{@var{file}.34.sched2}.
3372 Dump after CSE (including the jump optimization that sometimes follows
3373 CSE), to @file{@var{file}.06.cse}.
3376 Dump after the first scheduling pass, to @file{@var{file}.24.sched}.
3379 Dump after the second CSE pass (including the jump optimization that
3380 sometimes follows CSE), to @file{@var{file}.18.cse2}.
3383 Dump after running tracer, to @file{@var{file}.15.tracer}.
3386 Dump after null pointer elimination pass to @file{@var{file}.05.null}.
3389 Dump callgraph and unit-at-a-time optimization @file{@var{file}.00.unit}.
3392 Dump after the value profile transformations, to @file{@var{file}.13.vpt}.
3393 Also dump after variable tracking, to @file{@var{file}.35.vartrack}.
3396 Dump after the second flow pass, to @file{@var{file}.28.flow2}.
3399 Dump after the peephole pass, to @file{@var{file}.29.peephole2}.
3402 Dump after constructing the web, to @file{@var{file}.17.web}.
3405 Produce all the dumps listed above.
3408 Produce a core dump whenever an error occurs.
3411 Print statistics on memory usage, at the end of the run, to
3415 Annotate the assembler output with a comment indicating which
3416 pattern and alternative was used. The length of each instruction is
3420 Dump the RTL in the assembler output as a comment before each instruction.
3421 Also turns on @option{-dp} annotation.
3424 For each of the other indicated dump files (except for
3425 @file{@var{file}.01.rtl}), dump a representation of the control flow graph
3426 suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}.
3429 Just generate RTL for a function instead of compiling it. Usually used
3433 Dump debugging information during parsing, to standard error.
3436 @item -fdump-unnumbered
3437 @opindex fdump-unnumbered
3438 When doing debugging dumps (see @option{-d} option above), suppress instruction
3439 numbers and line number note output. This makes it more feasible to
3440 use diff on debugging dumps for compiler invocations with different
3441 options, in particular with and without @option{-g}.
3443 @item -fdump-translation-unit @r{(C and C++ only)}
3444 @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)}
3445 @opindex fdump-translation-unit
3446 Dump a representation of the tree structure for the entire translation
3447 unit to a file. The file name is made by appending @file{.tu} to the
3448 source file name. If the @samp{-@var{options}} form is used, @var{options}
3449 controls the details of the dump as described for the
3450 @option{-fdump-tree} options.
3452 @item -fdump-class-hierarchy @r{(C++ only)}
3453 @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)}
3454 @opindex fdump-class-hierarchy
3455 Dump a representation of each class's hierarchy and virtual function
3456 table layout to a file. The file name is made by appending @file{.class}
3457 to the source file name. If the @samp{-@var{options}} form is used,
3458 @var{options} controls the details of the dump as described for the
3459 @option{-fdump-tree} options.
3461 @item -fdump-tree-@var{switch} @r{(C and C++ only)}
3462 @itemx -fdump-tree-@var{switch}-@var{options} @r{(C and C++ only)}
3464 Control the dumping at various stages of processing the intermediate
3465 language tree to a file. The file name is generated by appending a switch
3466 specific suffix to the source file name. If the @samp{-@var{options}}
3467 form is used, @var{options} is a list of @samp{-} separated options that
3468 control the details of the dump. Not all options are applicable to all
3469 dumps, those which are not meaningful will be ignored. The following
3470 options are available
3474 Print the address of each node. Usually this is not meaningful as it
3475 changes according to the environment and source file. Its primary use
3476 is for tying up a dump file with a debug environment.
3478 Inhibit dumping of members of a scope or body of a function merely
3479 because that scope has been reached. Only dump such items when they
3480 are directly reachable by some other path. When dumping pretty-printed
3481 trees, this option inhibits dumping the bodies of control structures.
3483 Print a raw representation of the tree. By default, trees are
3484 pretty-printed into a C-like representation.
3486 Enable more detailed dumps (not honored by every dump option).
3488 Enable dumping various statistics about the pass (not honored by every dump
3491 Enable showing basic block boundaries (disabled in raw dumps).
3493 Enable showing virtual operands for every statement.
3495 Enable showing line numbers for statements.
3497 Enable showing the unique ID (@code{DECL_UID}) for each variable.
3499 Turn on all options, except @option{raw}, @option{slim} and @option{lineno}.
3502 The following tree dumps are possible:
3506 Dump before any tree based optimization, to @file{@var{file}.original}.
3509 Dump after all tree based optimization, to @file{@var{file}.optimized}.
3512 Dump after function inlining, to @file{@var{file}.inlined}.
3515 @opindex fdump-tree-gimple
3516 Dump each function before and after the gimplification pass to a file. The
3517 file name is made by appending @file{.gimple} to the source file name.
3520 @opindex fdump-tree-cfg
3521 Dump the control flow graph of each function to a file. The file name is
3522 made by appending @file{.cfg} to the source file name.
3525 @opindex fdump-tree-vcg
3526 Dump the control flow graph of each function to a file in VCG format. The
3527 file name is made by appending @file{.vcg} to the source file name. Note
3528 that if the file contains more than one function, the generated file cannot
3529 be used directly by VCG. You will need to cut and paste each function's
3530 graph into its own separate file first.
3533 @opindex fdump-tree-ch
3534 Dump each function after copying loop headers. The file name is made by
3535 appending @file{.ch} to the source file name.
3538 @opindex fdump-tree-ssa
3539 Dump SSA related information to a file. The file name is made by appending
3540 @file{.ssa} to the source file name.
3543 @opindex fdump-tree-alias
3544 Dump aliasing information for each function. The file name is made by
3545 appending @file{.alias} to the source file name.
3548 @opindex fdump-tree-ccp
3549 Dump each function after CCP. The file name is made by appending
3550 @file{.ccp} to the source file name.
3553 @opindex fdump-tree-pre
3554 Dump trees after partial redundancy elimination. The file name is made
3555 by appending @file{.pre} to the source file name.
3558 @opindex fdump-tree-fre
3559 Dump trees after full redundancy elimination. The file name is made
3560 by appending @file{.fre} to the source file name.
3563 @opindex fdump-tree-dce
3564 Dump each function after dead code elimination. The file name is made by
3565 appending @file{.dce} to the source file name.
3568 @opindex fdump-tree-mudflap
3569 Dump each function after adding mudflap instrumentation. The file name is
3570 made by appending @file{.mudflap} to the source file name.
3573 @opindex fdump-tree-sra
3574 Dump each function after performing scalar replacement of aggregates. The
3575 file name is made by appending @file{.sra} to the source file name.
3578 @opindex fdump-tree-dom
3579 Dump each function after applying dominator tree optimizations. The file
3580 name is made by appending @file{.dom} to the source file name.
3583 @opindex fdump-tree-dse
3584 Dump each function after applying dead store elimination. The file
3585 name is made by appending @file{.dse} to the source file name.
3588 @opindex fdump-tree-phiopt
3589 Dump each function after optimizing PHI nodes into straightline code. The file
3590 name is made by appending @file{.phiopt} to the source file name.
3593 @opindex fdump-tree-forwprop
3594 Dump each function after forward propagating single use variables. The file
3595 name is made by appending @file{.forwprop} to the source file name.
3598 @opindex fdump-tree-copyrename
3599 Dump each function after applying the copy rename optimization. The file
3600 name is made by appending @file{.copyrename} to the source file name.
3603 @opindex fdump-tree-nrv
3604 Dump each function after applying the named return value optimization on
3605 generic trees. The file name is made by appending @file{.nrv} to the source
3609 @opindex fdump-tree-all
3610 Enable all the available tree dumps with the flags provided in this option.
3613 @item -frandom-seed=@var{string}
3614 @opindex frandom-string
3615 This option provides a seed that GCC uses when it would otherwise use
3616 random numbers. It is used to generate certain symbol names
3617 that have to be different in every compiled file. It is also used to
3618 place unique stamps in coverage data files and the object files that
3619 produce them. You can use the @option{-frandom-seed} option to produce
3620 reproducibly identical object files.
3622 The @var{string} should be different for every file you compile.
3624 @item -fsched-verbose=@var{n}
3625 @opindex fsched-verbose
3626 On targets that use instruction scheduling, this option controls the
3627 amount of debugging output the scheduler prints. This information is
3628 written to standard error, unless @option{-dS} or @option{-dR} is
3629 specified, in which case it is output to the usual dump
3630 listing file, @file{.sched} or @file{.sched2} respectively. However
3631 for @var{n} greater than nine, the output is always printed to standard
3634 For @var{n} greater than zero, @option{-fsched-verbose} outputs the
3635 same information as @option{-dRS}. For @var{n} greater than one, it
3636 also output basic block probabilities, detailed ready list information
3637 and unit/insn info. For @var{n} greater than two, it includes RTL
3638 at abort point, control-flow and regions info. And for @var{n} over
3639 four, @option{-fsched-verbose} also includes dependence info.
3643 Store the usual ``temporary'' intermediate files permanently; place them
3644 in the current directory and name them based on the source file. Thus,
3645 compiling @file{foo.c} with @samp{-c -save-temps} would produce files
3646 @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a
3647 preprocessed @file{foo.i} output file even though the compiler now
3648 normally uses an integrated preprocessor.
3652 Report the CPU time taken by each subprocess in the compilation
3653 sequence. For C source files, this is the compiler proper and assembler
3654 (plus the linker if linking is done). The output looks like this:
3661 The first number on each line is the ``user time,'' that is time spent
3662 executing the program itself. The second number is ``system time,''
3663 time spent executing operating system routines on behalf of the program.
3664 Both numbers are in seconds.
3666 @item -fvar-tracking
3667 @opindex fvar-tracking
3668 Run variable tracking pass. It computes where variables are stored at each
3669 position in code. Better debugging information is then generated
3670 (if the debugging information format supports this information).
3672 It is enabled by default when compiling with optimization (@option{-Os},
3673 @option{-O}, @option{-O2}, ...), debugging information (@option{-g}) and
3674 the debug info format supports it.
3676 @item -print-file-name=@var{library}
3677 @opindex print-file-name
3678 Print the full absolute name of the library file @var{library} that
3679 would be used when linking---and don't do anything else. With this
3680 option, GCC does not compile or link anything; it just prints the
3683 @item -print-multi-directory
3684 @opindex print-multi-directory
3685 Print the directory name corresponding to the multilib selected by any
3686 other switches present in the command line. This directory is supposed
3687 to exist in @env{GCC_EXEC_PREFIX}.
3689 @item -print-multi-lib
3690 @opindex print-multi-lib
3691 Print the mapping from multilib directory names to compiler switches
3692 that enable them. The directory name is separated from the switches by
3693 @samp{;}, and each switch starts with an @samp{@@} instead of the
3694 @samp{-}, without spaces between multiple switches. This is supposed to
3695 ease shell-processing.
3697 @item -print-prog-name=@var{program}
3698 @opindex print-prog-name
3699 Like @option{-print-file-name}, but searches for a program such as @samp{cpp}.
3701 @item -print-libgcc-file-name
3702 @opindex print-libgcc-file-name
3703 Same as @option{-print-file-name=libgcc.a}.
3705 This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs}
3706 but you do want to link with @file{libgcc.a}. You can do
3709 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
3712 @item -print-search-dirs
3713 @opindex print-search-dirs
3714 Print the name of the configured installation directory and a list of
3715 program and library directories @command{gcc} will search---and don't do anything else.
3717 This is useful when @command{gcc} prints the error message
3718 @samp{installation problem, cannot exec cpp0: No such file or directory}.
3719 To resolve this you either need to put @file{cpp0} and the other compiler
3720 components where @command{gcc} expects to find them, or you can set the environment
3721 variable @env{GCC_EXEC_PREFIX} to the directory where you installed them.
3722 Don't forget the trailing '/'.
3723 @xref{Environment Variables}.
3726 @opindex dumpmachine
3727 Print the compiler's target machine (for example,
3728 @samp{i686-pc-linux-gnu})---and don't do anything else.
3731 @opindex dumpversion
3732 Print the compiler version (for example, @samp{3.0})---and don't do
3737 Print the compiler's built-in specs---and don't do anything else. (This
3738 is used when GCC itself is being built.) @xref{Spec Files}.
3740 @item -feliminate-unused-debug-types
3741 @opindex feliminate-unused-debug-types
3742 Normally, when producing DWARF2 output, GCC will emit debugging
3743 information for all types declared in a compilation
3744 unit, regardless of whether or not they are actually used
3745 in that compilation unit. Sometimes this is useful, such as
3746 if, in the debugger, you want to cast a value to a type that is
3747 not actually used in your program (but is declared). More often,
3748 however, this results in a significant amount of wasted space.
3749 With this option, GCC will avoid producing debug symbol output
3750 for types that are nowhere used in the source file being compiled.
3753 @node Optimize Options
3754 @section Options That Control Optimization
3755 @cindex optimize options
3756 @cindex options, optimization
3758 These options control various sorts of optimizations.
3760 Without any optimization option, the compiler's goal is to reduce the
3761 cost of compilation and to make debugging produce the expected
3762 results. Statements are independent: if you stop the program with a
3763 breakpoint between statements, you can then assign a new value to any
3764 variable or change the program counter to any other statement in the
3765 function and get exactly the results you would expect from the source
3768 Turning on optimization flags makes the compiler attempt to improve
3769 the performance and/or code size at the expense of compilation time
3770 and possibly the ability to debug the program.
3772 The compiler performs optimization based on the knowledge it has of
3773 the program. Optimization levels @option{-O2} and above, in
3774 particular, enable @emph{unit-at-a-time} mode, which allows the
3775 compiler to consider information gained from later functions in
3776 the file when compiling a function. Compiling multiple files at
3777 once to a single output file in @emph{unit-at-a-time} mode allows
3778 the compiler to use information gained from all of the files when
3779 compiling each of them.
3781 Not all optimizations are controlled directly by a flag. Only
3782 optimizations that have a flag are listed.
3789 Optimize. Optimizing compilation takes somewhat more time, and a lot
3790 more memory for a large function.
3792 With @option{-O}, the compiler tries to reduce code size and execution
3793 time, without performing any optimizations that take a great deal of
3796 @option{-O} turns on the following optimization flags:
3797 @gccoptlist{-fdefer-pop @gol
3798 -fmerge-constants @gol
3800 -floop-optimize @gol
3801 -fif-conversion @gol
3802 -fif-conversion2 @gol
3803 -fdelayed-branch @gol
3804 -fguess-branch-probability @gol
3807 @option{-O} also turns on @option{-fomit-frame-pointer} on machines
3808 where doing so does not interfere with debugging.
3812 Optimize even more. GCC performs nearly all supported optimizations
3813 that do not involve a space-speed tradeoff. The compiler does not
3814 perform loop unrolling or function inlining when you specify @option{-O2}.
3815 As compared to @option{-O}, this option increases both compilation time
3816 and the performance of the generated code.
3818 @option{-O2} turns on all optimization flags specified by @option{-O}. It
3819 also turns on the following optimization flags:
3820 @gccoptlist{-fforce-mem @gol
3821 -foptimize-sibling-calls @gol
3822 -fstrength-reduce @gol
3823 -fcse-follow-jumps -fcse-skip-blocks @gol
3824 -frerun-cse-after-loop -frerun-loop-opt @gol
3825 -fgcse -fgcse-lm -fgcse-sm -fgcse-las @gol
3826 -fdelete-null-pointer-checks @gol
3827 -fexpensive-optimizations @gol
3829 -fschedule-insns -fschedule-insns2 @gol
3830 -fsched-interblock -fsched-spec @gol
3833 -freorder-blocks -freorder-functions @gol
3834 -fstrict-aliasing @gol
3835 -funit-at-a-time @gol
3836 -falign-functions -falign-jumps @gol
3837 -falign-loops -falign-labels @gol
3840 Please note the warning under @option{-fgcse} about
3841 invoking @option{-O2} on programs that use computed gotos.
3845 Optimize yet more. @option{-O3} turns on all optimizations specified by
3846 @option{-O2} and also turns on the @option{-finline-functions},
3847 @option{-fweb}, @option{-frename-registers}
3848 and @option{-fgcse-after-reload} options.
3852 Do not optimize. This is the default.
3856 Optimize for size. @option{-Os} enables all @option{-O2} optimizations that
3857 do not typically increase code size. It also performs further
3858 optimizations designed to reduce code size.
3860 @option{-Os} disables the following optimization flags:
3861 @gccoptlist{-falign-functions -falign-jumps -falign-loops @gol
3862 -falign-labels -freorder-blocks -freorder-blocks-and-partition -fprefetch-loop-arrays}
3864 If you use multiple @option{-O} options, with or without level numbers,
3865 the last such option is the one that is effective.
3868 Options of the form @option{-f@var{flag}} specify machine-independent
3869 flags. Most flags have both positive and negative forms; the negative
3870 form of @option{-ffoo} would be @option{-fno-foo}. In the table
3871 below, only one of the forms is listed---the one you typically will
3872 use. You can figure out the other form by either removing @samp{no-}
3875 The following options control specific optimizations. They are either
3876 activated by @option{-O} options or are related to ones that are. You
3877 can use the following flags in the rare cases when ``fine-tuning'' of
3878 optimizations to be performed is desired.
3881 @item -fno-default-inline
3882 @opindex fno-default-inline
3883 Do not make member functions inline by default merely because they are
3884 defined inside the class scope (C++ only). Otherwise, when you specify
3885 @w{@option{-O}}, member functions defined inside class scope are compiled
3886 inline by default; i.e., you don't need to add @samp{inline} in front of
3887 the member function name.
3889 @item -fno-defer-pop
3890 @opindex fno-defer-pop
3891 Always pop the arguments to each function call as soon as that function
3892 returns. For machines which must pop arguments after a function call,
3893 the compiler normally lets arguments accumulate on the stack for several
3894 function calls and pops them all at once.
3896 Disabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3900 Force memory operands to be copied into registers before doing
3901 arithmetic on them. This produces better code by making all memory
3902 references potential common subexpressions. When they are not common
3903 subexpressions, instruction combination should eliminate the separate
3906 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3909 @opindex fforce-addr
3910 Force memory address constants to be copied into registers before
3911 doing arithmetic on them. This may produce better code just as
3912 @option{-fforce-mem} may.
3914 @item -fomit-frame-pointer
3915 @opindex fomit-frame-pointer
3916 Don't keep the frame pointer in a register for functions that
3917 don't need one. This avoids the instructions to save, set up and
3918 restore frame pointers; it also makes an extra register available
3919 in many functions. @strong{It also makes debugging impossible on
3922 On some machines, such as the VAX, this flag has no effect, because
3923 the standard calling sequence automatically handles the frame pointer
3924 and nothing is saved by pretending it doesn't exist. The
3925 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
3926 whether a target machine supports this flag. @xref{Registers,,Register
3927 Usage, gccint, GNU Compiler Collection (GCC) Internals}.
3929 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
3931 @item -foptimize-sibling-calls
3932 @opindex foptimize-sibling-calls
3933 Optimize sibling and tail recursive calls.
3935 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
3939 Don't pay attention to the @code{inline} keyword. Normally this option
3940 is used to keep the compiler from expanding any functions inline.
3941 Note that if you are not optimizing, no functions can be expanded inline.
3943 @item -finline-functions
3944 @opindex finline-functions
3945 Integrate all simple functions into their callers. The compiler
3946 heuristically decides which functions are simple enough to be worth
3947 integrating in this way.
3949 If all calls to a given function are integrated, and the function is
3950 declared @code{static}, then the function is normally not output as
3951 assembler code in its own right.
3953 Enabled at level @option{-O3}.
3955 @item -finline-limit=@var{n}
3956 @opindex finline-limit
3957 By default, GCC limits the size of functions that can be inlined. This flag
3958 allows the control of this limit for functions that are explicitly marked as
3959 inline (i.e., marked with the inline keyword or defined within the class
3960 definition in c++). @var{n} is the size of functions that can be inlined in
3961 number of pseudo instructions (not counting parameter handling). The default
3962 value of @var{n} is 600.
3963 Increasing this value can result in more inlined code at
3964 the cost of compilation time and memory consumption. Decreasing usually makes
3965 the compilation faster and less code will be inlined (which presumably
3966 means slower programs). This option is particularly useful for programs that
3967 use inlining heavily such as those based on recursive templates with C++.
3969 Inlining is actually controlled by a number of parameters, which may be
3970 specified individually by using @option{--param @var{name}=@var{value}}.
3971 The @option{-finline-limit=@var{n}} option sets some of these parameters
3975 @item max-inline-insns-single
3976 is set to @var{n}/2.
3977 @item max-inline-insns-auto
3978 is set to @var{n}/2.
3979 @item min-inline-insns
3980 is set to 130 or @var{n}/4, whichever is smaller.
3981 @item max-inline-insns-rtl
3985 See below for a documentation of the individual
3986 parameters controlling inlining.
3988 @emph{Note:} pseudo instruction represents, in this particular context, an
3989 abstract measurement of function's size. In no way, it represents a count
3990 of assembly instructions and as such its exact meaning might change from one
3991 release to an another.
3993 @item -fkeep-inline-functions
3994 @opindex fkeep-inline-functions
3995 Even if all calls to a given function are integrated, and the function
3996 is declared @code{static}, nevertheless output a separate run-time
3997 callable version of the function. This switch does not affect
3998 @code{extern inline} functions.
4000 @item -fkeep-static-consts
4001 @opindex fkeep-static-consts
4002 Emit variables declared @code{static const} when optimization isn't turned
4003 on, even if the variables aren't referenced.
4005 GCC enables this option by default. If you want to force the compiler to
4006 check if the variable was referenced, regardless of whether or not
4007 optimization is turned on, use the @option{-fno-keep-static-consts} option.
4009 @item -fmerge-constants
4010 Attempt to merge identical constants (string constants and floating point
4011 constants) across compilation units.
4013 This option is the default for optimized compilation if the assembler and
4014 linker support it. Use @option{-fno-merge-constants} to inhibit this
4017 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4019 @item -fmerge-all-constants
4020 Attempt to merge identical constants and identical variables.
4022 This option implies @option{-fmerge-constants}. In addition to
4023 @option{-fmerge-constants} this considers e.g. even constant initialized
4024 arrays or initialized constant variables with integral or floating point
4025 types. Languages like C or C++ require each non-automatic variable to
4026 have distinct location, so using this option will result in non-conforming
4029 @item -fmodulo-sched
4030 @opindex fmodulo-sched
4031 Perform swing modulo scheduling immediately before the first scheduling
4032 pass. This pass looks at innermost loops and reorders their
4033 instructions by overlapping different iterations.
4037 Use a graph coloring register allocator. Currently this option is meant
4038 only for testing. Users should not specify this option, since it is not
4039 yet ready for production use.
4041 @item -fno-branch-count-reg
4042 @opindex fno-branch-count-reg
4043 Do not use ``decrement and branch'' instructions on a count register,
4044 but instead generate a sequence of instructions that decrement a
4045 register, compare it against zero, then branch based upon the result.
4046 This option is only meaningful on architectures that support such
4047 instructions, which include x86, PowerPC, IA-64 and S/390.
4049 The default is @option{-fbranch-count-reg}, enabled when
4050 @option{-fstrength-reduce} is enabled.
4052 @item -fno-function-cse
4053 @opindex fno-function-cse
4054 Do not put function addresses in registers; make each instruction that
4055 calls a constant function contain the function's address explicitly.
4057 This option results in less efficient code, but some strange hacks
4058 that alter the assembler output may be confused by the optimizations
4059 performed when this option is not used.
4061 The default is @option{-ffunction-cse}
4063 @item -fno-zero-initialized-in-bss
4064 @opindex fno-zero-initialized-in-bss
4065 If the target supports a BSS section, GCC by default puts variables that
4066 are initialized to zero into BSS@. This can save space in the resulting
4069 This option turns off this behavior because some programs explicitly
4070 rely on variables going to the data section. E.g., so that the
4071 resulting executable can find the beginning of that section and/or make
4072 assumptions based on that.
4074 The default is @option{-fzero-initialized-in-bss}.
4076 @item -fbounds-check
4077 @opindex fbounds-check
4078 For front-ends that support it, generate additional code to check that
4079 indices used to access arrays are within the declared range. This is
4080 currently only supported by the Java and Fortran front-ends, where
4081 this option defaults to true and false respectively.
4083 @item -fmudflap -fmudflapth -fmudflapir
4087 @cindex bounds checking
4089 For front-ends that support it (C and C++), instrument all risky
4090 pointer/array dereferencing operations, some standard library
4091 string/heap functions, and some other associated constructs with
4092 range/validity tests. Modules so instrumented should be immune to
4093 buffer overflows, invalid heap use, and some other classes of C/C++
4094 programming errors. The instrumentation relies on a separate runtime
4095 library (@file{libmudflap}), which will be linked into a program if
4096 @option{-fmudflap} is given at link time. Run-time behavior of the
4097 instrumented program is controlled by the @env{MUDFLAP_OPTIONS}
4098 environment variable. See @code{env MUDFLAP_OPTIONS=-help a.out}
4101 Use @option{-fmudflapth} instead of @option{-fmudflap} to compile and to
4102 link if your program is multi-threaded. Use @option{-fmudflapir}, in
4103 addition to @option{-fmudflap} or @option{-fmudflapth}, if
4104 instrumentation should ignore pointer reads. This produces less
4105 instrumentation (and therefore faster execution) and still provides
4106 some protection against outright memory corrupting writes, but allows
4107 erroneously read data to propagate within a program.
4109 @item -fstrength-reduce
4110 @opindex fstrength-reduce
4111 Perform the optimizations of loop strength reduction and
4112 elimination of iteration variables.
4114 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4116 @item -fthread-jumps
4117 @opindex fthread-jumps
4118 Perform optimizations where we check to see if a jump branches to a
4119 location where another comparison subsumed by the first is found. If
4120 so, the first branch is redirected to either the destination of the
4121 second branch or a point immediately following it, depending on whether
4122 the condition is known to be true or false.
4124 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4126 @item -fcse-follow-jumps
4127 @opindex fcse-follow-jumps
4128 In common subexpression elimination, scan through jump instructions
4129 when the target of the jump is not reached by any other path. For
4130 example, when CSE encounters an @code{if} statement with an
4131 @code{else} clause, CSE will follow the jump when the condition
4134 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4136 @item -fcse-skip-blocks
4137 @opindex fcse-skip-blocks
4138 This is similar to @option{-fcse-follow-jumps}, but causes CSE to
4139 follow jumps which conditionally skip over blocks. When CSE
4140 encounters a simple @code{if} statement with no else clause,
4141 @option{-fcse-skip-blocks} causes CSE to follow the jump around the
4142 body of the @code{if}.
4144 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4146 @item -frerun-cse-after-loop
4147 @opindex frerun-cse-after-loop
4148 Re-run common subexpression elimination after loop optimizations has been
4151 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4153 @item -frerun-loop-opt
4154 @opindex frerun-loop-opt
4155 Run the loop optimizer twice.
4157 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4161 Perform a global common subexpression elimination pass.
4162 This pass also performs global constant and copy propagation.
4164 @emph{Note:} When compiling a program using computed gotos, a GCC
4165 extension, you may get better runtime performance if you disable
4166 the global common subexpression elimination pass by adding
4167 @option{-fno-gcse} to the command line.
4169 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4173 When @option{-fgcse-lm} is enabled, global common subexpression elimination will
4174 attempt to move loads which are only killed by stores into themselves. This
4175 allows a loop containing a load/store sequence to be changed to a load outside
4176 the loop, and a copy/store within the loop.
4178 Enabled by default when gcse is enabled.
4182 When @option{-fgcse-sm} is enabled, a store motion pass is run after
4183 global common subexpression elimination. This pass will attempt to move
4184 stores out of loops. When used in conjunction with @option{-fgcse-lm},
4185 loops containing a load/store sequence can be changed to a load before
4186 the loop and a store after the loop.
4188 Enabled by default when gcse is enabled.
4192 When @option{-fgcse-las} is enabled, the global common subexpression
4193 elimination pass eliminates redundant loads that come after stores to the
4194 same memory location (both partial and full redundancies).
4196 Enabled by default when gcse is enabled.
4198 @item -fgcse-after-reload
4199 @opindex fgcse-after-reload
4200 When @option{-fgcse-after-reload} is enabled, a redundant load elimination
4201 pass is performed after reload. The purpose of this pass is to cleanup
4204 @item -floop-optimize
4205 @opindex floop-optimize
4206 Perform loop optimizations: move constant expressions out of loops, simplify
4207 exit test conditions and optionally do strength-reduction and loop unrolling as
4210 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4212 @item -floop-optimize2
4213 @opindex floop-optimize2
4214 Perform loop optimizations using the new loop optimizer. The optimizations
4215 (loop unrolling, peeling and unswitching, loop invariant motion) are enabled
4218 @item -fcrossjumping
4219 @opindex crossjumping
4220 Perform cross-jumping transformation. This transformation unifies equivalent code and save code size. The
4221 resulting code may or may not perform better than without cross-jumping.
4223 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4225 @item -fif-conversion
4226 @opindex if-conversion
4227 Attempt to transform conditional jumps into branch-less equivalents. This
4228 include use of conditional moves, min, max, set flags and abs instructions, and
4229 some tricks doable by standard arithmetics. The use of conditional execution
4230 on chips where it is available is controlled by @code{if-conversion2}.
4232 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4234 @item -fif-conversion2
4235 @opindex if-conversion2
4236 Use conditional execution (where available) to transform conditional jumps into
4237 branch-less equivalents.
4239 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4241 @item -fdelete-null-pointer-checks
4242 @opindex fdelete-null-pointer-checks
4243 Use global dataflow analysis to identify and eliminate useless checks
4244 for null pointers. The compiler assumes that dereferencing a null
4245 pointer would have halted the program. If a pointer is checked after
4246 it has already been dereferenced, it cannot be null.
4248 In some environments, this assumption is not true, and programs can
4249 safely dereference null pointers. Use
4250 @option{-fno-delete-null-pointer-checks} to disable this optimization
4251 for programs which depend on that behavior.
4253 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4255 @item -fexpensive-optimizations
4256 @opindex fexpensive-optimizations
4257 Perform a number of minor optimizations that are relatively expensive.
4259 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4261 @item -foptimize-register-move
4263 @opindex foptimize-register-move
4265 Attempt to reassign register numbers in move instructions and as
4266 operands of other simple instructions in order to maximize the amount of
4267 register tying. This is especially helpful on machines with two-operand
4270 Note @option{-fregmove} and @option{-foptimize-register-move} are the same
4273 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4275 @item -fdelayed-branch
4276 @opindex fdelayed-branch
4277 If supported for the target machine, attempt to reorder instructions
4278 to exploit instruction slots available after delayed branch
4281 Enabled at levels @option{-O}, @option{-O2}, @option{-O3}, @option{-Os}.
4283 @item -fschedule-insns
4284 @opindex fschedule-insns
4285 If supported for the target machine, attempt to reorder instructions to
4286 eliminate execution stalls due to required data being unavailable. This
4287 helps machines that have slow floating point or memory load instructions
4288 by allowing other instructions to be issued until the result of the load
4289 or floating point instruction is required.
4291 Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
4293 @item -fschedule-insns2
4294 @opindex fschedule-insns2
4295 Similar to @option{-fschedule-insns}, but requests an additional pass of
4296 instruction scheduling after register allocation has been done. This is
4297 especially useful on machines with a relatively small number of
4298 registers and where memory load instructions take more than one cycle.