@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, @c 2000, 2001, 2002, 2003 Free Software Foundation, Inc. @c This is part of the GCC manual. @c For copying conditions, see the file gcc.texi. @ignore @c man begin COPYRIGHT Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being ``GNU General Public License'' and ``Funding Free Software'', the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the gfdl(7) man page. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. @c man end @c Set file name and title for the man page. @setfilename gcc @settitle GNU project C and C++ compiler @c man begin SYNOPSIS gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}] [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] [@option{-o} @var{outfile}] @var{infile}@dots{} Only the most useful options are listed here; see below for the remainder. @samp{g++} accepts mostly the same options as @samp{gcc}. @c APPLE LOCAL begin manual Note: In Apple's version of GCC, both @samp{cc} and @samp{gcc} are actually symbolic links to @samp{gcc-3.3}, while @samp{c++} and @samp{g++} are links to @samp{g++-3.3}, unless the @command{gcc_select(1)} command has been used to point them at another compiler version. Note that Apple's GCC includes a number of extensions to standard GCC (flagged below with ``APPLE ONLY''), and that not all generic GCC options are available or supported on Darwin / Mac OS X. In particular, Apple does not currently support the compilation of Fortran, Ada, or Java, although there are third parties who have made these work. @c APPLE LOCAL begin manual @c man end @c man begin SEEALSO gpl(7), gfdl(7), fsf-funding(7), cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1), gcc_select(1) and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as}, @file{ld}, @file{binutils} and @file{gdb}. @c man end @c man begin BUGS @c APPLE LOCAL begin report bugs to Apple To report bugs to Apple, see @w{@uref{http://developer.apple.com/bugreporter}}. @c APPLE LOCAL end report bugs to Apple @c man end @c man begin AUTHOR See the Info entry for @command{gcc}, or @w{@uref{http://gcc.gnu.org/onlinedocs/gcc/Contributors.html}}, for contributors to GCC@. @c man end @end ignore @node Invoking GCC @chapter GCC Command Options @cindex GCC command options @cindex command options @cindex options, GCC command @c man begin DESCRIPTION When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The ``overall options'' allow you to stop this process at an intermediate stage. For example, the @option{-c} option says not to run the linker. Then the output consists of object files output by the assembler. Other options are passed on to one stage of processing. Some options control the preprocessor and others the compiler itself. Yet other options control the assembler and linker; most of these are not documented here, since you rarely need to use any of them. @cindex C compilation options Most of the command line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages. @cindex C++ compilation options @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special options for compiling C++ programs. @cindex grouping options @cindex options, grouping The @command{gcc} program accepts options and file names as operands. Many options have multi-letter names; therefore multiple single-letter options may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d -r}}. @cindex order of options @cindex options, order You can mix options and other arguments. For the most part, the order you use doesn't matter. Order does matter when you use several options of the same kind; for example, if you specify @option{-L} more than once, the directories are searched in the order specified. Many options have long names starting with @samp{-f} or with @samp{-W}---for example, @option{-fforce-mem}, @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of these have both positive and negative forms; the negative form of @option{-ffoo} would be @option{-fno-foo}. This manual documents only one of these two forms, whichever one is not the default. @c man end @xref{Option Index}, for an index to GCC's options. @menu * Option Summary:: Brief list of all options, without explanations. * Overall Options:: Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. * Invoking G++:: Compiling C++ programs. * C Dialect Options:: Controlling the variant of C language compiled. * C++ Dialect Options:: Variations on C++. @c APPLE LOCAL begin Objective-C++ * Objective-C Dialect Options:: Variations on Objective-C and (APPLE ONLY) Objective-C++. @c APPLE LOCAL end Objective-C++ * Language Independent Options:: Controlling how diagnostics should be formatted. * Warning Options:: How picky should the compiler be? * Debugging Options:: Symbol tables, measurements, and debugging dumps. * Optimize Options:: How much optimization? * Preprocessor Options:: Controlling header files and macro definitions. Also, getting dependency information for Make. * Assembler Options:: Passing options to the assembler. * Link Options:: Specifying libraries and so on. * Directory Options:: Where to find header files and libraries. Where to find the compiler executable files. * Spec Files:: How to pass switches to sub-processes. * Target Options:: Running a cross-compiler, or an old version of GCC. * Submodel Options:: Specifying minor hardware or convention variations, such as 68010 vs 68020. * Code Gen Options:: Specifying conventions for function calls, data layout and register usage. * Environment Variables:: Env vars that affect GCC. * Precompiled Headers:: Compiling a header once, and using it many times. * Running Protoize:: Automatically adding or removing function prototypes. @end menu @c man begin OPTIONS @node Option Summary @section Option Summary Here is a summary of all the options, grouped by type. Explanations are in the following sections. @table @emph @item Overall Options @xref{Overall Options,,Options Controlling the Kind of Output}. @gccoptlist{ -c -S -E -o @var{file} -pipe -pass-exit-codes -x @var{language} @gol @c APPLE LOCAL -ObjC 2001-08-03 sts ** -ObjC (APPLE ONLY) -ObjC++ (APPLE ONLY) @gol @c APPLE LOCAL fat builds -arch @var{arch} (APPLE ONLY) @gol -v -### --help --target-help --version} @item C Language Options @xref{C Dialect Options,,Options Controlling C Dialect}. @gccoptlist{ -ansi -std=@var{standard} -aux-info @var{filename} @gol @c APPLE LOCAL AltiVec -faltivec (APPLE ONLY) @gol @c APPLE LOCAL CW asm blocks -fasm-blocks (APPLE ONLY) @gol -fno-asm -fno-builtin -fno-builtin-@var{function} @gol -fhosted -ffreestanding -fms-extensions @gol -trigraphs -no-integrated-cpp -traditional -traditional-cpp @gol -fallow-single-precision -fcond-mismatch @gol @c APPLE LOCAL constant cfstrings mrs -fconstant-cfstrings (APPLE ONLY) @gol @c APPLE LOCAL pch distcc mrs -fpch-preprocess (APPLE ONLY) @gol -fsigned-bitfields -fsigned-char @gol -funsigned-bitfields -funsigned-char @gol @c APPLE LOCAL Pascal strings 2001-07-05 zll ** -fpascal-strings (APPLE ONLY) @gol @c APPLE LOCAL coalescing 2002-04-11 tur ** -fcoalesce (APPLE ONLY) -fweak-coalesced (APPLE ONLY) @gol @c APPLE LOCAL -Wno-#warnings -Wno-#warnings (APPLE ONLY) @gol @c APPLE LOCAL -Wextra-tokens 2001-08-02 sts ** -Wextra-tokens (APPLE ONLY) @gol @c APPLE LOCAL -Wpragma-once 2001-08-01 sts ** -Wpragma-once (APPLE ONLY) @gol @c APPLE LOCAL -Wnewline-eof 2001-08-23 sts ** -Wnewline-eof (APPLE ONLY) @gol @c APPLE LOCAL -Wno-altivec-long-deprecated ilr ** -Wno-altivec-long-deprecated (APPLE ONLY) -fwritable-strings} @item C++ Language Options @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. @gccoptlist{ -fabi-version=@var{n} -fno-access-control -fcheck-new @gol -fconserve-space -fno-const-strings -fdollars-in-identifiers @gol -fno-elide-constructors @gol -fno-enforce-eh-specs -fexternal-templates @gol -falt-external-templates @gol -ffor-scope -fno-for-scope -fno-gnu-keywords @gol -fno-implicit-templates @gol -fno-implicit-inline-templates @gol -fno-implement-inlines @gol @c APPLE LOCAL -findirect-virtual-calls 2001-10-30 sts ** -findirect-virtual-calls (APPLE ONLY) @gol @c APPLE LOCAL -fapple-kext -fapple-kext (APPLE ONLY) @gol @c APPLE LOCAL coalescing 2002-04-11 tur ** -fcoalesce-templates (APPLE ONLY) @gol -fms-extensions @gol -fno-nonansi-builtins -fno-operator-names @gol -fno-optional-diags -fpermissive @gol -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol -fuse-cxa-atexit -fvtable-gc -fno-weak -nostdinc++ @gol -fno-default-inline -Wabi -Wctor-dtor-privacy @gol -Wnon-virtual-dtor -Wreorder @gol -Weffc++ -Wno-deprecated @gol -Wno-non-template-friend -Wold-style-cast @gol -Woverloaded-virtual -Wno-pmf-conversions @gol -Wsign-promo -Wsynth} @item Objective-C Language Options @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}. @gccoptlist{ -fconstant-string-class=@var{class-name} @gol @c APPLE LOCAL begin ObjC options -fgnu-runtime -fnext-runtime @gol -fno-nil-receivers (APPLE ONLY) @gol -fobjc-exceptions (APPLE ONLY) @gol -freplace-objc-classes (APPLE ONLY) @gol -fzero-link (APPLE ONLY) @gol @c APPLE LOCAL end ObjC options -gen-decls @gol -Wno-protocol -Wselector -Wundeclared-selector} @item Language Independent Options @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}. @gccoptlist{ -fmessage-length=@var{n} @gol -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}} @item Warning Options @xref{Warning Options,,Options to Request or Suppress Warnings}. @gccoptlist{ -fsyntax-only -pedantic -pedantic-errors @gol -w -W -Wall -Waggregate-return @gol -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol -Wconversion -Wno-deprecated-declarations @gol -Wdisabled-optimization -Wno-div-by-zero -Werror @gol -Wfloat-equal -Wformat -Wformat=2 @gol -Wformat-nonliteral -Wformat-security @gol -Wimplicit -Wimplicit-int @gol -Wimplicit-function-declaration @gol -Werror-implicit-function-declaration @gol -Wimport -Winline -Winvalid-pch -Wno-endif-labels @gol @c APPLE LOCAL Radar 3247235 suppress warnings for bad uses of offsetof -Wno-invalid-offsetof (APPLE ONLY) @gol -Wlarger-than-@var{len} -Wlong-long @gol @c APPLE LOCAL -Wlong-double -Wno-long-double (APPLE ONLY) @gol -Wmain -Wmissing-braces @gol -Wmissing-format-attribute -Wmissing-noreturn @gol @c APPLE LOCAL -Wmost -Wmost (APPLE ONLY) @gol -Wno-multichar -Wno-format-extra-args -Wno-format-y2k @gol -Wno-import -Wnonnull -Wpacked -Wpadded @gol -Wparentheses -Wpointer-arith -Wredundant-decls @gol -Wreturn-type -Wsequence-point -Wshadow @gol -Wsign-compare -Wstrict-aliasing @gol -Wswitch -Wswitch-default -Wswitch-enum @gol -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol -Wunknown-pragmas -Wunreachable-code @gol -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol -Wunused-value -Wunused-variable -Wwrite-strings} @item C-only Warning Options @gccoptlist{ -Wbad-function-cast -Wmissing-declarations @gol -Wmissing-prototypes -Wnested-externs @gol -Wstrict-prototypes -Wtraditional} @item Debugging Options @xref{Debugging Options,,Options for Debugging Your Program or GCC}. @gccoptlist{ -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol -fdump-tree-original@r{[}-@var{n}@r{]} -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol -feliminate-dwarf2-dups -fmem-report @gol -fprofile-arcs -fsched-verbose=@var{n} @gol -ftest-coverage -ftime-report @gol -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol -ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+ @gol -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol -print-multi-directory -print-multi-lib @gol -print-prog-name=@var{program} -print-search-dirs -Q @gol @c APPLE LOCAL Symbol Separation @c APPLE LOCAL -fsave-repository and -grepository -save-temps -time -fsave-repository=@var{location} -grepository} @item Optimization Options @xref{Optimize Options,,Options that Control Optimization}. @gccoptlist{ -falign-functions=@var{n} -falign-jumps=@var{n} @gol -falign-labels=@var{n} -falign-loops=@var{n} @gol -falign-loops-max-skip=@var{n} -falign-jumps-max-skip=@var{n} @gol -fbranch-probabilities -fcaller-saves -fcprop-registers @gol -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol -fdelayed-branch -fdelete-null-pointer-checks @gol -fexpensive-optimizations -ffast-math -ffloat-store @gol -fforce-addr -fforce-mem -ffunction-sections @gol -fgcse -fgcse-lm -fgcse-sm -floop-optimize -fcrossjumping @gol -fif-conversion -fif-conversion2 @gol -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol -fmove-all-movables -fnew-ra -fno-branch-count-reg @gol -fno-default-inline -fno-defer-pop @gol -fno-function-cse -fno-guess-branch-probability @gol -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol -funsafe-math-optimizations -ffinite-math-only @gol -fno-trapping-math -fno-zero-initialized-in-bss @gol -fomit-frame-pointer -foptimize-register-move @gol -foptimize-sibling-calls -fprefetch-loop-arrays @gol -freduce-all-givs -fregmove -frename-registers @gol -freorder-blocks -freorder-functions @gol -frerun-cse-after-loop -frerun-loop-opt @gol -fschedule-insns -fschedule-insns2 @gol -fno-sched-interblock -fno-sched-spec -fsched-spec-load @gol -fsched-spec-load-dangerous -fsignaling-nans @gol -fsingle-precision-constant -fssa -fssa-ccp -fssa-dce @gol -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps @gol -funroll-all-loops -funroll-loops @gol --param @var{name}=@var{value} @c APPLE LOCAL -fast -O -O0 -O1 -O2 -O3 -Os -fast (APPLE ONLY)} @item Preprocessor Options @xref{Preprocessor Options,,Options Controlling the Preprocessor}. @gccoptlist{ -$ -A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol -C -dD -dI -dM -dN @gol -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol -idirafter @var{dir} @gol -include @var{file} -imacros @var{file} @gol -iprefix @var{file} -iwithprefix @var{dir} @gol -iwithprefixbefore @var{dir} -isystem @var{dir} @gol -M -MM -MF -MG -MP -MQ -MT -nostdinc -P -remap @gol @c APPLE LOCAL -dependency-file -dependency-file (APPLE ONLY) @gol -trigraphs -undef -U@var{macro} -Wp,@var{option}} @item Assembler Option @xref{Assembler Options,,Passing Options to the Assembler}. @gccoptlist{ -Wa,@var{option}} @item Linker Options @xref{Link Options,,Options for Linking}. @gccoptlist{ @var{object-file-name} -l@var{library} @gol @c APPLE LOCAL radar 2466994 - -no-c++filt ilr -nostartfiles -nodefaultlibs -nostdlib -no-c++filt (APPLE ONLY) @gol -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol -Wl,@var{option} -Xlinker @var{option} @gol -u @var{symbol}} @item Directory Options @xref{Directory Options,,Options for Directory Search}. @gccoptlist{ -B@var{prefix} -I@var{dir} -I- @gol @c APPLE LOCAL framework headers -F@var{dir} (APPLE ONLY) @gol -L@var{dir} -specs=@var{file}} @item Target Options @c I wrote this xref this way to avoid overfull hbox. -- rms @xref{Target Options}. @gccoptlist{ -V @var{version} -b @var{machine}} @item Machine Dependent Options @xref{Submodel Options,,Hardware Models and Configurations}. @c APPLE LOCAL prune man page @ignore @emph{M680x0 Options} @gccoptlist{ -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol -mfpa -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol -malign-int -mstrict-align} @emph{M68hc1x Options} @gccoptlist{ -m6811 -m6812 -m68hc11 -m68hc12 -m68hcs12 @gol -mauto-incdec -minmax -mlong-calls -mshort @gol -msoft-reg-count=@var{count}} @emph{VAX Options} @gccoptlist{ -mg -mgnu -munix} @emph{SPARC Options} @gccoptlist{ -mcpu=@var{cpu-type} @gol -mtune=@var{cpu-type} @gol -mcmodel=@var{code-model} @gol -m32 -m64 @gol -mapp-regs -mbroken-saverestore -mcypress @gol -mfaster-structs -mflat @gol -mfpu -mhard-float -mhard-quad-float @gol -mimpure-text -mlive-g0 -mno-app-regs @gol -mno-faster-structs -mno-flat -mno-fpu @gol -mno-impure-text -mno-stack-bias -mno-unaligned-doubles @gol -msoft-float -msoft-quad-float -msparclite -mstack-bias @gol -msupersparc -munaligned-doubles -mv8} @emph{ARM Options} @gccoptlist{ -mapcs-frame -mno-apcs-frame @gol -mapcs-26 -mapcs-32 @gol -mapcs-stack-check -mno-apcs-stack-check @gol -mapcs-float -mno-apcs-float @gol -mapcs-reentrant -mno-apcs-reentrant @gol -msched-prolog -mno-sched-prolog @gol -mlittle-endian -mbig-endian -mwords-little-endian @gol -malignment-traps -mno-alignment-traps @gol -msoft-float -mhard-float -mfpe @gol -mthumb-interwork -mno-thumb-interwork @gol -mcpu=@var{name} -march=@var{name} -mfpe=@var{name} @gol -mstructure-size-boundary=@var{n} @gol -mabort-on-noreturn @gol -mlong-calls -mno-long-calls @gol -msingle-pic-base -mno-single-pic-base @gol -mpic-register=@var{reg} @gol -mnop-fun-dllimport @gol -mpoke-function-name @gol -mthumb -marm @gol -mtpcs-frame -mtpcs-leaf-frame @gol -mcaller-super-interworking -mcallee-super-interworking } @emph{MN10200 Options} @gccoptlist{ -mrelax} @emph{MN10300 Options} @gccoptlist{ -mmult-bug -mno-mult-bug @gol -mam33 -mno-am33 @gol -mno-crt0 -mrelax} @emph{M32R/D Options} @gccoptlist{ -m32rx -m32r -mcode-model=@var{model-type} -msdata=@var{sdata-type} @gol -G @var{num}} @emph{M88K Options} @gccoptlist{ -m88000 -m88100 -m88110 -mbig-pic @gol -mcheck-zero-division -mhandle-large-shift @gol -midentify-revision -mno-check-zero-division @gol -mno-ocs-debug-info -mno-ocs-frame-position @gol -mno-optimize-arg-area -mno-serialize-volatile @gol -mno-underscores -mocs-debug-info @gol -mocs-frame-position -moptimize-arg-area @gol -mserialize-volatile -mshort-data-@var{num} -msvr3 @gol -msvr4 -mtrap-large-shift -muse-div-instruction @gol -mversion-03.00 -mwarn-passed-structs} @c APPLE LOCAL prune man page @end ignore @emph{RS/6000 and PowerPC Options} @gccoptlist{ -mcpu=@var{cpu-type} @gol -mtune=@var{cpu-type} @gol -mpower -mno-power -mpower2 -mno-power2 @gol -mpowerpc -mpowerpc64 -mno-powerpc @gol -maltivec -mno-altivec @gol -mpowerpc-gpopt -mno-powerpc-gpopt @gol -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol -mnew-mnemonics -mold-mnemonics @gol -mfull-toc -mminimal-toc -mno-fp-in-toc -mno-sum-in-toc @gol -m64 -m32 -mxl-call -mno-xl-call -mpe @gol @c APPLE LOCAL begin -malign-mac68k -malign-mac68k (APPLE ONLY) @gol -malign-power (APPLE ONLY) @gol -malign-natural (APPLE ONLY) @gol @c APPLE LOCAL end -malign-mac68k -msoft-float -mhard-float -mmultiple -mno-multiple @gol -mstring -mno-string -mupdate -mno-update @gol -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol -mstrict-align -mno-strict-align -mrelocatable @gol -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol @c APPLE LOCAL dynamic-no-pic -mdynamic-no-pic (APPLE ONLY) @gol @c APPLE LOCAL long-branch -mlong-branch (APPLE ONLY) @gol -mcall-aix -mcall-sysv -mcall-netbsd @gol -maix-struct-return -msvr4-struct-return @gol -mabi=altivec -mabi=no-altivec @gol -mabi=spe -mabi=no-spe @gol -misel=yes -misel=no @gol -mprototype -mno-prototype @gol -msim -mmvme -mads -myellowknife -memb -msdata @gol -msdata=@var{opt} -mvxworks -mwindiss -G @var{num} -pthread} @emph{Darwin Options} @gccoptlist{ -all_load -allowable_client -arch -arch_errors_fatal @gol -arch_only -bind_at_load -bundle -bundle_loader @gol -client_name -compatibility_version -current_version @gol -dead_strip -no_dead_strip_inits_and_terms @gol -dependency-file -dylib_file -dylinker_install_name @gol -dynamic -dynamiclib -exported_symbols_list @gol -filelist -flat_namespace -force_cpusubtype_ALL @gol -force_flat_namespace -headerpad_max_install_names @gol -image_base -init -install_name -keep_private_externs @gol -multi_module -multiply_defined -multiply_defined_unused @gol -noall_load -nomultidefs -noprebind -noseglinkedit @gol -pagezero_size -prebind -prebind_all_twolevel_modules @gol -private_bundle -read_only_relocs -sectalign @gol -sectobjectsymbols -whyload -seg1addr @gol -sectcreate -sectobjectsymbols -sectorder @gol -seg_addr_table -seg_addr_table_filename -seglinkedit @gol -segprot -segs_read_only_addr -segs_read_write_addr @gol -single_module -static -sub_library -sub_umbrella @gol -twolevel_namespace -umbrella -undefined @gol -unexported_symbols_list -weak_reference_mismatches -whatsloaded} @c APPLE LOCAL prune man page @ignore @emph{RT Options} @gccoptlist{ -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs @gol -mfull-fp-blocks -mhc-struct-return -min-line-mul @gol -mminimum-fp-blocks -mnohc-struct-return} @emph{MIPS Options} @gccoptlist{ -mabicalls -march=@var{cpu-type} -mtune=@var{cpu=type} @gol -mcpu=@var{cpu-type} -membedded-data -muninit-const-in-rodata @gol -membedded-pic -mfp32 -mfp64 -mfused-madd -mno-fused-madd @gol -mgas -mgp32 -mgp64 @gol -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 @gol -mips2 -mips3 -mips4 -mlong64 -mlong32 -mlong-calls -mmemcpy @gol -mmips-as -mmips-tfile -mno-abicalls @gol -mno-embedded-data -mno-uninit-const-in-rodata @gol -mno-embedded-pic -mno-gpopt -mno-long-calls @gol -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats @gol -mrnames -msoft-float @gol -m4650 -msingle-float -mmad @gol -mstats -EL -EB -G @var{num} -nocpp @gol -mabi=32 -mabi=n32 -mabi=64 -mabi=eabi @gol -mfix7000 -mno-crt0 -mflush-func=@var{func} -mno-flush-func @gol -mbranch-likely -mno-branch-likely} @c APPLE LOCAL prune man page @end ignore @emph{i386 and x86-64 Options} @gccoptlist{ -mcpu=@var{cpu-type} -march=@var{cpu-type} -mfpmath=@var{unit} @gol -masm=@var{dialect} -mno-fancy-math-387 @gol -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol -mno-wide-multiply -mrtd -malign-double @gol -mpreferred-stack-boundary=@var{num} @gol -mmmx -msse -msse2 -m3dnow @gol -mthreads -mno-align-stringops -minline-all-stringops @gol -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer @gol -mno-red-zone@gol -mcmodel=@var{code-model} @gol -m32 -m64} @c APPLE LOCAL prune man page @ignore @emph{HPPA Options} @gccoptlist{ -march=@var{architecture-type} @gol -mbig-switch -mdisable-fpregs -mdisable-indexing @gol -mfast-indirect-calls -mgas -mgnu-ld -mhp-ld @gol -mjump-in-delay -mlinker-opt -mlong-calls @gol -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol -mno-jump-in-delay -mno-long-load-store @gol -mno-portable-runtime -mno-soft-float @gol -mno-space-regs -msoft-float -mpa-risc-1-0 @gol -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol -mschedule=@var{cpu-type} -mspace-regs -msio -mwsio} @emph{Intel 960 Options} @gccoptlist{ -m@var{cpu-type} -masm-compat -mclean-linkage @gol -mcode-align -mcomplex-addr -mleaf-procedures @gol -mic-compat -mic2.0-compat -mic3.0-compat @gol -mintel-asm -mno-clean-linkage -mno-code-align @gol -mno-complex-addr -mno-leaf-procedures @gol -mno-old-align -mno-strict-align -mno-tail-call @gol -mnumerics -mold-align -msoft-float -mstrict-align @gol -mtail-call} @emph{DEC Alpha Options} @gccoptlist{ -mno-fp-regs -msoft-float -malpha-as -mgas @gol -mieee -mieee-with-inexact -mieee-conformant @gol -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol -mtrap-precision=@var{mode} -mbuild-constants @gol -mcpu=@var{cpu-type} -mtune=@var{cpu-type} @gol -mbwx -mmax -mfix -mcix @gol -mfloat-vax -mfloat-ieee @gol -mexplicit-relocs -msmall-data -mlarge-data @gol -mmemory-latency=@var{time}} @emph{DEC Alpha/VMS Options} @gccoptlist{ -mvms-return-codes} @emph{H8/300 Options} @gccoptlist{ -mrelax -mh -ms -mn -mint32 -malign-300} @emph{SH Options} @gccoptlist{ -m1 -m2 -m3 -m3e @gol -m4-nofpu -m4-single-only -m4-single -m4 @gol -m5-64media -m5-64media-nofpu @gol -m5-32media -m5-32media-nofpu @gol -m5-compact -m5-compact-nofpu @gol -mb -ml -mdalign -mrelax @gol -mbigtable -mfmovd -mhitachi -mnomacsave @gol -mieee -misize -mpadstruct -mspace @gol -mprefergot -musermode} @emph{System V Options} @gccoptlist{ -Qy -Qn -YP,@var{paths} -Ym,@var{dir}} @emph{ARC Options} @gccoptlist{ -EB -EL @gol -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol -mdata=@var{data-section} -mrodata=@var{readonly-data-section}} @emph{TMS320C3x/C4x Options} @gccoptlist{ -mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol -mparallel-insns -mparallel-mpy -mpreserve-float} @emph{V850 Options} @gccoptlist{ -mlong-calls -mno-long-calls -mep -mno-ep @gol -mprolog-function -mno-prolog-function -mspace @gol -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol -mapp-regs -mno-app-regs @gol -mdisable-callt -mno-disable-callt @gol -mv850e @gol -mv850 -mbig-switch} @emph{NS32K Options} @gccoptlist{ -m32032 -m32332 -m32532 -m32081 -m32381 @gol -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol -mregparam -mnoregparam -msb -mnosb @gol -mbitfield -mnobitfield -mhimem -mnohimem} @emph{AVR Options} @gccoptlist{ -mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol -mcall-prologues -mno-tablejump -mtiny-stack} @emph{MCore Options} @gccoptlist{ -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} @emph{MMIX Options} @gccoptlist{ -mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu @gol -mabi=mmixware -mzero-extend -mknuthdiv -mtoplevel-symbols @gol -melf -mbranch-predict -mno-branch-predict -mbase-addresses @gol -mno-base-addresses -msingle-exit -mno-single-exit} @emph{IA-64 Options} @gccoptlist{ -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol -mconstant-gp -mauto-pic -minline-float-divide-min-latency @gol -minline-float-divide-max-throughput -minline-int-divide-min-latency @gol -minline-int-divide-max-throughput -mno-dwarf2-asm @gol -mfixed-range=@var{register-range}} @emph{D30V Options} @gccoptlist{ -mextmem -mextmemory -monchip -mno-asm-optimize @gol -masm-optimize -mbranch-cost=@var{n} -mcond-exec=@var{n}} @emph{S/390 and zSeries Options} @gccoptlist{ -mhard-float -msoft-float -mbackchain -mno-backchain @gol -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol -m64 -m31 -mdebug -mno-debug} @emph{CRIS Options} @gccoptlist{ -mcpu=@var{cpu} -march=@var{cpu} -mtune=@var{cpu} @gol -mmax-stack-frame=@var{n} -melinux-stacksize=@var{n} @gol -metrax4 -metrax100 -mpdebug -mcc-init -mno-side-effects @gol -mstack-align -mdata-align -mconst-align @gol -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue -mno-gotplt @gol -melf -maout -melinux -mlinux -sim -sim2} @emph{PDP-11 Options} @gccoptlist{ -mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol -mbcopy -mbcopy-builtin -mint32 -mno-int16 @gol -mint16 -mno-int32 -mfloat32 -mno-float64 @gol -mfloat64 -mno-float32 -mabshi -mno-abshi @gol -mbranch-expensive -mbranch-cheap @gol -msplit -mno-split -munix-asm -mdec-asm} @emph{Xstormy16 Options} @gccoptlist{ -msim} @emph{Xtensa Options} @gccoptlist{ -mbig-endian -mlittle-endian @gol -mdensity -mno-density @gol -mmac16 -mno-mac16 @gol -mmul16 -mno-mul16 @gol -mmul32 -mno-mul32 @gol -mnsa -mno-nsa @gol -mminmax -mno-minmax @gol -msext -mno-sext @gol -mbooleans -mno-booleans @gol -mhard-float -msoft-float @gol -mfused-madd -mno-fused-madd @gol -mserialize-volatile -mno-serialize-volatile @gol -mtext-section-literals -mno-text-section-literals @gol -mtarget-align -mno-target-align @gol -mlongcalls -mno-longcalls} @emph{FRV Options} @gccoptlist{ -mgpr-32 -mgpr-64 -mfpr-32 -mfpr-64 -mhard-float -msoft-float @gol -malloc-cc -mfixed-cc -mdword -mno-dword -mdouble -mno-double @gol -mmedia -mno-media -mmuladd -mno-muladd -mlibrary-pic -macc-4 @gol -macc-8 -mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol -mscc -mno-scc -mcond-exec -mno-cond-exec -mvliw-branch -mno-vliw-branch @gol -mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol -mno-nested-cond-exec -mtomcat-stats @gol -mcpu=@var{cpu}} @c APPLE LOCAL prune man page @end ignore @item Code Generation Options @xref{Code Gen Options,,Options for Code Generation Conventions}. @gccoptlist{ -fcall-saved-@var{reg} -fcall-used-@var{reg} @gol -ffixed-@var{reg} -fexceptions @gol -fnon-call-exceptions -funwind-tables @gol -fasynchronous-unwind-tables @gol -finhibit-size-directive -finstrument-functions @gol -fno-common -fno-ident -fno-gnu-linker @gol -fpcc-struct-return -fpic -fPIC @gol -freg-struct-return -fshared-data -fshort-enums @gol -fshort-double -fshort-wchar -fvolatile @gol -fvolatile-global -fvolatile-static @gol -fverbose-asm -fpack-struct -fstack-check @gol -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol -fargument-alias -fargument-noalias @gol -fargument-noalias-global -fleading-underscore @gol -ftls-model=@var{model} @gol -ftrapv -fbounds-check} @end table @menu * Overall Options:: Controlling the kind of output: an executable, object files, assembler files, or preprocessed source. * C Dialect Options:: Controlling the variant of C language compiled. * C++ Dialect Options:: Variations on C++. * Objective-C Dialect Options:: Variations on Objective-C. * Language Independent Options:: Controlling how diagnostics should be formatted. * Warning Options:: How picky should the compiler be? * Debugging Options:: Symbol tables, measurements, and debugging dumps. * Optimize Options:: How much optimization? * Preprocessor Options:: Controlling header files and macro definitions. Also, getting dependency information for Make. * Assembler Options:: Passing options to the assembler. * Link Options:: Specifying libraries and so on. * Directory Options:: Where to find header files and libraries. Where to find the compiler executable files. * Spec Files:: How to pass switches to sub-processes. * Target Options:: Running a cross-compiler, or an old version of GCC. @end menu @node Overall Options @section Options Controlling the Kind of Output Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. The first three stages apply to an individual source file, and end by producing an object file; linking combines all the object files (those newly compiled, and those specified as input) into an executable file. @cindex file name suffix For any given input file, the file name suffix determines what kind of compilation is done: @table @gcctabopt @item @var{file}.c C source code which must be preprocessed. @item @var{file}.i C source code which should not be preprocessed. @item @var{file}.ii C++ source code which should not be preprocessed. @item @var{file}.m Objective-C source code. Note that you must link with the library @file{libobjc.a} to make an Objective-C program work. @item @var{file}.mi Objective-C source code which should not be preprocessed. @item @var{file}.h C or C++ header file to be turned into a precompiled header. @item @var{file}.cc @itemx @var{file}.cp @itemx @var{file}.cxx @itemx @var{file}.cpp @itemx @var{file}.c++ @itemx @var{file}.C C++ source code which must be preprocessed. Note that in @samp{.cxx}, the last two letters must both be literally @samp{x}. Likewise, @samp{.C} refers to a literal capital C@. @c APPLE LOCAL begin Objective-C++ @item @var{file}.mm @itemx @var{file}.M Objective-C++ source code which must be preprocessed. (APPLE ONLY) @item @var{file}.mii Objective-C++ source code which should not be preprocessed. (APPLE ONLY) @c APPLE LOCAL end Objective-C++ @item @var{file}.hh @itemx @var{file}.H C++ header file to be turned into a precompiled header. @item @var{file}.f @itemx @var{file}.for @itemx @var{file}.FOR Fortran source code which should not be preprocessed. @item @var{file}.F @itemx @var{file}.fpp @itemx @var{file}.FPP Fortran source code which must be preprocessed (with the traditional preprocessor). @item @var{file}.r Fortran source code which must be preprocessed with a RATFOR preprocessor (not included with GCC)@. @xref{Overall Options,,Options Controlling the Kind of Output, g77, Using and Porting GNU Fortran}, for more details of the handling of Fortran input files. @c FIXME: Descriptions of Java file types. @c @var{file}.java @c @var{file}.class @c @var{file}.zip @c @var{file}.jar @item @var{file}.ads Ada source code file which contains a library unit declaration (a declaration of a package, subprogram, or generic, or a generic instantiation), or a library unit renaming declaration (a package, generic, or subprogram renaming declaration). Such files are also called @dfn{specs}. @itemx @var{file}.adb Ada source code file containing a library unit body (a subprogram or package body). Such files are also called @dfn{bodies}. @c GCC also knows about some suffixes for languages not yet included: @c Pascal: @c @var{file}.p @c @var{file}.pas @item @var{file}.s @c APPLE LOCAL preprocess .s files Assembler code. Apple's version of GCC runs the preprocessor on these files as well as those ending in @samp{.S}. @item @var{file}.S Assembler code which must be preprocessed. @item @var{other} An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way. @end table @opindex x You can specify the input language explicitly with the @option{-x} option: @table @gcctabopt @item -x @var{language} Specify explicitly the @var{language} for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next @option{-x} option. Possible values for @var{language} are: @example c c-header cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objc-cpp-output @c APPLE LOCAL Objective-C++ objective-c++ (APPLE ONLY) objective-c++-header (APPLE ONLY) assembler assembler-with-cpp ada f77 f77-cpp-input ratfor java treelang @end example @item -x none Turn off any specification of a language, so that subsequent files are handled according to their file name suffixes (as they are if @option{-x} has not been used at all). @c APPLE LOCAL begin -ObjC 2001-08-03 sts ** @item -ObjC @item -ObjC++ @opindex ObjC @opindex ObjC++ These are similar in effect to @option{-x objective-c} and @option{-x objective-c++}, but also cause the @option{-ObjC} flag to be passed to @command{ld(1)}, causing static archive libraries that define an Objective-C class or category to be linked in in their entirety. (APPLE ONLY) @c APPLE LOCAL end -ObjC 2001-08-03 sts ** @c APPLE LOCAL begin fat builds @item -arch @var{arch} Compile for the specified target architecture @var{arch}. The allowable values are @samp{i386} and @samp{ppc}. Multiple options work, and direct the compiler to produce ``fat'' binaries including object code for each architecture specified with @option{-arch}. This option only works if assembler and libraries are available for each architecture specified. (APPLE ONLY) @opindex arch @c APPLE LOCAL end fat builds @item -pass-exit-codes @opindex pass-exit-codes Normally the @command{gcc} program will exit with the code of 1 if any phase of the compiler returns a non-success return code. If you specify @option{-pass-exit-codes}, the @command{gcc} program will instead return with numerically highest error produced by any phase that returned an error indication. @end table If you only want some of the stages of compilation, you can use @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and one of the options @option{-c}, @option{-S}, or @option{-E} to say where @command{gcc} is to stop. Note that some combinations (for example, @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. @table @gcctabopt @item -c @opindex c Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file. By default, the object file name for a source file is made by replacing the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. Unrecognized input files, not requiring compilation or assembly, are ignored. @item -S @opindex S Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified. By default, the assembler file name for a source file is made by replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. Input files that don't require compilation are ignored. @item -E @opindex E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output. Input files which don't require preprocessing are ignored. @cindex output file option @item -o @var{file} @opindex o Place output in file @var{file}. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code. Since only one output file can be specified, it does not make sense to use @option{-o} when compiling more than one input file, unless you are producing an executable file as output. If @option{-o} is not specified, the default is to put an executable file in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and all preprocessed C source on standard output. @item -v @opindex v Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper. @item -### @opindex ### Like @option{-v} except the commands are not executed and all command arguments are quoted. This is useful for shell scripts to capture the driver-generated command lines. @item -pipe @opindex pipe Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble. @item --help @opindex help Print (on the standard output) a description of the command line options understood by @command{gcc}. If the @option{-v} option is also specified then @option{--help} will also be passed on to the various processes invoked by @command{gcc}, so that they can display the command line options they accept. If the @option{-W} option is also specified then command line options which have no documentation associated with them will also be displayed. @item --target-help @opindex target-help Print (on the standard output) a description of target specific command line options for each tool. @item --version @opindex version Display the version number and copyrights of the invoked GCC. @end table @node Invoking G++ @section Compiling C++ Programs @c APPLE LOCAL .CPP extension @c FSF Candidate - Submitted @cindex suffixes for C++ source @cindex C++ source file suffixes C++ source files conventionally use one of the suffixes @samp{.C}, @samp{.cc}, @samp{.cpp}, @samp{.CPP}, @samp{.c++}, @samp{.cp}, or @samp{.cxx}; C++ header files often use @samp{.hh} or @samp{.H}; preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name @command{gcc}). @findex g++ @findex c++ However, C++ programs often require class libraries as well as a compiler that understands the C++ language---and under some circumstances, you might want to compile programs or header files from standard input, or otherwise without a suffix that flags them as C++ programs. You might also like to precompile a C header file with a @samp{.h} extension to be used in C++ compilations. @command{g++} is a program that calls GCC with the default language set to C++, and automatically specifies linking against the C++ library. On many systems, @command{g++} is also installed with the name @command{c++}. @cindex invoking @command{g++} When you compile C++ programs, you may specify many of the same command-line options that you use for compiling programs in any language; or command-line options meaningful for C and related languages; or options that are meaningful only for C++ programs. @xref{C Dialect Options,,Options Controlling C Dialect}, for explanations of options for languages related to C@. @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for explanations of options that are meaningful only for C++ programs. @node C Dialect Options @section Options Controlling C Dialect @cindex dialect options @cindex language dialect options @cindex options, dialect The following options control the dialect of C (or languages derived from C, such as C++ and Objective-C) that the compiler accepts: @table @gcctabopt @cindex ANSI support @cindex ISO support @item -ansi @opindex ansi In C mode, support all ISO C90 programs. In C++ mode, remove GNU extensions that conflict with ISO C++. This turns off certain features of GCC that are incompatible with ISO C90 (when compiling C code), or of standard C++ (when compiling C++ code), such as the @code{asm} and @code{typeof} keywords, and predefined macros such as @code{unix} and @code{vax} that identify the type of system you are using. It also enables the undesirable and rarely used ISO trigraph feature. For the C compiler, it disables recognition of C++ style @samp{//} comments as well as the @code{inline} keyword. The alternate keywords @code{__asm__}, @code{__extension__}, @code{__inline__} and @code{__typeof__} continue to work despite @option{-ansi}. You would not want to use them in an ISO C program, of course, but it is useful to put them in header files that might be included in compilations done with @option{-ansi}. Alternate predefined macros such as @code{__unix__} and @code{__vax__} are also available, with or without @option{-ansi}. The @option{-ansi} option does not cause non-ISO programs to be rejected gratuitously. For that, @option{-pedantic} is required in addition to @option{-ansi}. @xref{Warning Options}. The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} option is used. Some header files may notice this macro and refrain from declaring certain functions or defining certain macros that the ISO standard doesn't call for; this is to avoid interfering with any programs that might use these names for other things. Functions which would normally be built in but do not have semantics defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in functions with @option{-ansi} is used. @xref{Other Builtins,,Other built-in functions provided by GCC}, for details of the functions affected. @item -std= @opindex std Determine the language standard. This option is currently only supported when compiling C or C++. A value for this option must be provided; possible values are @table @samp @item c89 @itemx iso9899:1990 ISO C90 (same as @option{-ansi}). @item iso9899:199409 ISO C90 as modified in amendment 1. @item c99 @itemx c9x @itemx iso9899:1999 @itemx iso9899:199x ISO C99. Note that this standard is not yet fully supported; see @w{@uref{http://gcc.gnu.org/gcc-3.3/c99status.html}} for more information. The names @samp{c9x} and @samp{iso9899:199x} are deprecated. @item gnu89 Default, ISO C90 plus GNU extensions (including some C99 features). @item gnu99 @item gnu9x ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, this will become the default. The name @samp{gnu9x} is deprecated. @item c++98 The 1998 ISO C++ standard plus amendments. @item gnu++98 The same as @option{-std=c++98} plus GNU extensions. This is the default for C++ code. @end table Even when this option is not specified, you can still use some of the features of newer standards in so far as they do not conflict with previous C standards. For example, you may use @code{__restrict__} even when @option{-std=c99} is not specified. The @option{-std} options specifying some version of ISO C have the same effects as @option{-ansi}, except that features that were not in ISO C90 but are in the specified version (for example, @samp{//} comments and the @code{inline} keyword in ISO C99) are not disabled. @xref{Standards,,Language Standards Supported by GCC}, for details of these standard versions. @item -aux-info @var{filename} @opindex aux-info Output to the given filename prototyped declarations for all functions declared and/or defined in a translation unit, including those in header files. This option is silently ignored in any language other than C@. Besides declarations, the file indicates, in comments, the origin of each declaration (source file and line), whether the declaration was implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or @samp{O} for old, respectively, in the first character after the line number and the colon), and whether it came from a declaration or a definition (@samp{C} or @samp{F}, respectively, in the following character). In the case of function definitions, a K&R-style list of arguments followed by their declarations is also provided, inside comments, after the declaration. @c APPLE LOCAL begin AltiVec @item -faltivec Enable the AltiVec language extensions, as defined in Motorola's AltiVec PIM. This includes the recognition of @code{vector} and @code{pixel} as (context-dependent) keywords, the definition of built-in functions such as @code{vec_add}, and other extensions. Note that unlike the option @samp{-maltivec}, the extensions do not require the inclusion of any special header files. (APPLE ONLY) @c APPLE LOCAL end AltiVec @c APPLE LOCAL begin CW asm blocks @item -fasm-blocks Enable the use of blocks and entire functions of assembly code within a C or C++ file. The syntax follows that used in CodeWarrior. (APPLE ONLY) @c APPLE LOCAL end CW asm blocks @item -fno-asm @opindex fno-asm Do not recognize @code{asm}, @code{inline} or @code{typeof} as a keyword, so that code can use these words as identifiers. You can use the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} instead. @option{-ansi} implies @option{-fno-asm}. In C++, this switch only affects the @code{typeof} keyword, since @code{asm} and @code{inline} are standard keywords. You may want to use the @option{-fno-gnu-keywords} flag instead, which has the same effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this switch only affects the @code{asm} and @code{typeof} keywords, since @code{inline} is a standard keyword in ISO C99. @item -fno-builtin @itemx -fno-builtin-@var{function} @opindex fno-builtin @cindex built-in functions Don't recognize built-in functions that do not begin with @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in functions provided by GCC}, for details of the functions affected, including those which are not built-in functions when @option{-ansi} or @option{-std} options for strict ISO C conformance are used because they do not have an ISO standard meaning. GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to @code{alloca} may become single instructions that adjust the stack directly, and calls to @code{memcpy} may become inline copy loops. The resulting code is often both smaller and faster, but since the function calls no longer appear as such, you cannot set a breakpoint on those calls, nor can you change the behavior of the functions by linking with a different library. With the @option{-fno-builtin-@var{function}} option only the built-in function @var{function} is disabled. @var{function} must not begin with @samp{__builtin_}. If a function is named this is not built-in in this version of GCC, this option is ignored. There is no corresponding @option{-fbuiltin-@var{function}} option; if you wish to enable built-in functions selectively when using @option{-fno-builtin} or @option{-ffreestanding}, you may define macros such as: @smallexample #define abs(n) __builtin_abs ((n)) #define strcpy(d, s) __builtin_strcpy ((d), (s)) @end smallexample @item -fhosted @opindex fhosted @cindex hosted environment Assert that compilation takes place in a hosted environment. This implies @option{-fbuiltin}. A hosted environment is one in which the entire standard library is available, and in which @code{main} has a return type of @code{int}. Examples are nearly everything except a kernel. This is equivalent to @option{-fno-freestanding}. @item -ffreestanding @opindex ffreestanding @cindex hosted environment Assert that compilation takes place in a freestanding environment. This implies @option{-fno-builtin}. A freestanding environment is one in which the standard library may not exist, and program startup may not necessarily be at @code{main}. The most obvious example is an OS kernel. This is equivalent to @option{-fno-hosted}. @xref{Standards,,Language Standards Supported by GCC}, for details of freestanding and hosted environments. @item -fms-extensions @opindex fms-extensions Accept some non-standard constructs used in Microsoft header files. @item -trigraphs @opindex trigraphs Support ISO C trigraphs. The @option{-ansi} option (and @option{-std} options for strict ISO C conformance) implies @option{-trigraphs}. @item -no-integrated-cpp @opindex no-integrated-cpp Performs a compilation in two passes: preprocessing and compiling. This option allows a user supplied "cc1", "cc1plus", or "cc1obj" via the @option{-B} option. The user supplied compilation step can then add in an additional preprocessing step after normal preprocessing but before compiling. The default is to use the integrated cpp (internal cpp) The semantics of this option will change if "cc1", "cc1plus", and "cc1obj" are merged. @cindex traditional C language @cindex C language, traditional @item -traditional @itemx -traditional-cpp @opindex traditional-cpp @opindex traditional Formerly, these options caused GCC to attempt to emulate a pre-standard C compiler. They are now only supported with the @option{-E} switch. The preprocessor continues to support a pre-standard mode. See the GNU CPP manual for details. @item -fcond-mismatch @opindex fcond-mismatch Allow conditional expressions with mismatched types in the second and third arguments. The value of such an expression is void. This option is not supported for C++. @c APPLE LOCAL BEGIN pch distcc mrs @item -fpch-preprocess @opindex fpch-preprocess Enable PCH processing even when @option{-E} or @option{-save-temps} is used. @c APPLE LOCAL END pch distcc mrs @item -funsigned-char @opindex funsigned-char Let the type @code{char} be unsigned, like @code{unsigned char}. Each kind of machine has a default for what @code{char} should be. It is either like @code{unsigned char} by default or like @code{signed char} by default. Ideally, a portable program should always use @code{signed char} or @code{unsigned char} when it depends on the signedness of an object. But many programs have been written to use plain @code{char} and expect it to be signed, or expect it to be unsigned, depending on the machines they were written for. This option, and its inverse, let you make such a program work with the opposite default. The type @code{char} is always a distinct type from each of @code{signed char} or @code{unsigned char}, even though its behavior is always just like one of those two. @item -fsigned-char @opindex fsigned-char Let the type @code{char} be signed, like @code{signed char}. Note that this is equivalent to @option{-fno-unsigned-char}, which is the negative form of @option{-funsigned-char}. Likewise, the option @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. @item -fsigned-bitfields @itemx -funsigned-bitfields @itemx -fno-signed-bitfields @itemx -fno-unsigned-bitfields @opindex fsigned-bitfields @opindex funsigned-bitfields @opindex fno-signed-bitfields @opindex fno-unsigned-bitfields These options control whether a bit-field is signed or unsigned, when the declaration does not use either @code{signed} or @code{unsigned}. By default, such a bit-field is signed, because this is consistent: the basic integer types such as @code{int} are signed types. @item -fwritable-strings @opindex fwritable-strings Store string constants in the writable data segment and don't uniquize them. This is for compatibility with old programs which assume they can write into string constants. Writing into string constants is a very bad idea; ``constants'' should be constant. @c APPLE LOCAL begin constant cfstrings @item -fconstant-cfstrings @opindex fconstant-cfstrings Enable the automatic creation of a CoreFoundation-type constant string whenever a special builtin @code{__builtin__CFStringMakeConstantString} is called on a literal string, and for @code{@@"@dots{}"} literals in Objective-C (thus overriding the @option{-fconstant-string-class} setting). This option will also be enabled if the environment variable @code{MACOSX_DEPLOYMENT_TARGET} exists and is set to @code{"10.2"} or greater. (APPLE ONLY) @c APPLE LOCAL end constant cfstrings @c APPLE LOCAL begin Pascal strings 2001-07-05 zll ** @item -fpascal-strings Allow Pascal-style string literals to be constructed. (APPLE ONLY) @xref{Pascal Strings,,Constructing String Literals with a Pascal-style Length Byte}, for more information on the syntax and semantics of Pascal string literals. @c APPLE LOCAL end Pascal strings 2001-07-05 zll ** @c APPLE LOCAL begin coalescing 2002-04-11 turly ** @item -fcoalesce @opindex fcoalesce Coalesce duplicated functions and data. The linker will discard all but one, saving space. Enabled by default. (APPLE ONLY) @item -fweak-coalesced @opindex fweak-coalesced Use the new OS X "weak_definitions" section attribute for coalesced items. A single "normal" definition will be chosen by the linker over any number of weakly-coalesced ones. (APPLE ONLY) @c APPLE LOCAL end coalescing 2002-04-11 turly ** @end table @node C++ Dialect Options @section Options Controlling C++ Dialect @cindex compiler options, C++ @cindex C++ options, command line @cindex options, C++ This section describes the command-line options that are only meaningful for C++ programs; but you can also use most of the GNU compiler options regardless of what language your program is in. For example, you might compile a file @code{firstClass.C} like this: @example g++ -g -frepo -O -c firstClass.C @end example @noindent In this example, only @option{-frepo} is an option meant only for C++ programs; you can use the other options with any language supported by GCC@. Here is a list of options that are @emph{only} for compiling C++ programs: @table @gcctabopt @item -fabi-version=@var{n} @opindex fabi-version Use version @var{n} of the C++ ABI. Version 1 is the version of the C++ ABI that first appeared in G++ 3.2. Version 0 will always be the version that conforms most closely to the C++ ABI specification. Therefore, the ABI obtained using version 0 will change as ABI bugs are fixed. The default is version 1. @item -fno-access-control @opindex fno-access-control Turn off all access checking. This switch is mainly useful for working around bugs in the access control code. @item -fcheck-new @opindex fcheck-new Check that the pointer returned by @code{operator new} is non-null before attempting to modify the storage allocated. The current Working Paper requires that @code{operator new} never return a null pointer, so this check is normally unnecessary. An alternative to using this option is to specify that your @code{operator new} does not throw any exceptions; if you declare it @samp{throw()}, G++ will check the return value. See also @samp{new (nothrow)}. @item -fconserve-space @opindex fconserve-space Put uninitialized or runtime-initialized global variables into the common segment, as C does. This saves space in the executable at the cost of not diagnosing duplicate definitions. If you compile with this flag and your program mysteriously crashes after @code{main()} has completed, you may have an object that is being destroyed twice because two definitions were merged. This option is no longer useful on most targets, now that support has been added for putting variables into BSS without making them common. @item -fno-const-strings @opindex fno-const-strings Give string constants type @code{char *} instead of type @code{const char *}. By default, G++ uses type @code{const char *} as required by the standard. Even if you use @option{-fno-const-strings}, you cannot actually modify the value of a string constant, unless you also use @option{-fwritable-strings}. This option might be removed in a future release of G++. For maximum portability, you should structure your code so that it works with string constants that have type @code{const char *}. @item -fdollars-in-identifiers @opindex fdollars-in-identifiers Accept @samp{$} in identifiers. You can also explicitly prohibit use of @samp{$} with the option @option{-fno-dollars-in-identifiers}. (GNU C allows @samp{$} by default on most target systems, but there are a few exceptions.) Traditional C allowed the character @samp{$} to form part of identifiers. However, ISO C and C++ forbid @samp{$} in identifiers. @item -fno-elide-constructors @opindex fno-elide-constructors The C++ standard allows an implementation to omit creating a temporary which is only used to initialize another object of the same type. Specifying this option disables that optimization, and forces G++ to call the copy constructor in all cases. @item -fno-enforce-eh-specs @opindex fno-enforce-eh-specs Don't check for violation of exception specifications at runtime. This option violates the C++ standard, but may be useful for reducing code size in production builds, much like defining @samp{NDEBUG}. The compiler will still optimize based on the exception specifications. @item -fexternal-templates @opindex fexternal-templates Cause @samp{#pragma interface} and @samp{implementation} to apply to template instantiation; template instances are emitted or not according to the location of the template definition. @xref{Template Instantiation}, for more information. This option is deprecated. @item -falt-external-templates @opindex falt-external-templates Similar to @option{-fexternal-templates}, but template instances are emitted or not according to the place where they are first instantiated. @xref{Template Instantiation}, for more information. This option is deprecated. @item -ffor-scope @itemx -fno-for-scope @opindex ffor-scope @opindex fno-for-scope If @option{-ffor-scope} is specified, the scope of variables declared in a @i{for-init-statement} is limited to the @samp{for} loop itself, as specified by the C++ standard. If @option{-fno-for-scope} is specified, the scope of variables declared in a @i{for-init-statement} extends to the end of the enclosing scope, as was the case in old versions of G++, and other (traditional) implementations of C++. The default if neither flag is given to follow the standard, but to allow and give a warning for old-style code that would otherwise be invalid, or have different behavior. @item -fno-gnu-keywords @opindex fno-gnu-keywords Do not recognize @code{typeof} as a keyword, so that code can use this word as an identifier. You can use the keyword @code{__typeof__} instead. @option{-ansi} implies @option{-fno-gnu-keywords}. @item -fno-implicit-templates @opindex fno-implicit-templates Never emit code for non-inline templates which are instantiated implicitly (i.e.@: by use); only emit code for explicit instantiations. @xref{Template Instantiation}, for more information. @item -fno-implicit-inline-templates @opindex fno-implicit-inline-templates Don't emit code for implicit instantiations of inline templates, either. The default is to handle inlines differently so that compiles with and without optimization will need the same set of explicit instantiations. @item -fno-implement-inlines @opindex fno-implement-inlines To save space, do not emit out-of-line copies of inline functions controlled by @samp{#pragma implementation}. This will cause linker errors if these functions are not inlined everywhere they are called. @c APPLE LOCAL begin -findirect-virtual-calls 2001-10-30 sts ** @item -findirect-virtual-calls @opindex findirect-virtual-calls Do not make direct calls to virtual functions; instead, always go through the vtable. (APPLE ONLY) @c APPLE LOCAL end -findirect-virtual-calls 2001-10-30 sts ** @c APPLE LOCAL begin -fapple-kext @item -fapple-kext @opindex fapple-kext Alter vtables, destructors, and other implementation details to more closely resemble the GCC 2.95 ABI. This is to make kernel extensions loadable by Darwin kernels, and is required to build any Darwin kernel extension. @option{-fno-exceptions} and @option{-static} must also be used with this flag. (APPLE ONLY) @c APPLE LOCAL end -fapple-kext @c APPLE LOCAL begin coalescing 2002-04-11 turly ** @item -fcoalesce-templates @opindex fcoalesce-templates Mark instantiated templates as "coalesced": the linker will discard all but one, thus saving space. (APPLE ONLY) @c APPLE LOCAL end coalescing 2002-04-11 turly ** @item -fms-extensions @opindex fms-extensions Disable pedantic warnings about constructs used in MFC, such as implicit int and getting a pointer to member function via non-standard syntax. @item -fno-nonansi-builtins @opindex fno-nonansi-builtins Disable built-in declarations of functions that are not mandated by ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, @code{index}, @code{bzero}, @code{conjf}, and other related functions. @item -fno-operator-names @opindex fno-operator-names Do not treat the operator name keywords @code{and}, @code{bitand}, @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as synonyms as keywords. @item -fno-optional-diags @opindex fno-optional-diags Disable diagnostics that the standard says a compiler does not need to issue. Currently, the only such diagnostic issued by G++ is the one for a name having multiple meanings within a class. @item -fpermissive @opindex fpermissive Downgrade messages about nonconformant code from errors to warnings. By default, G++ effectively sets @option{-pedantic-errors} without @option{-pedantic}; this option reverses that. This behavior and this option are superseded by @option{-pedantic}, which works as it does for GNU C@. @item -frepo @opindex frepo Enable automatic template instantiation at link time. This option also implies @option{-fno-implicit-templates}. @xref{Template Instantiation}, for more information. @item -fno-rtti @opindex fno-rtti Disable generation of information about every class with virtual functions for use by the C++ runtime type identification features (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts of the language, you can save some space by using this flag. Note that exception handling uses the same information, but it will generate it as needed. @c APPLE LOCAL begin jet @item -fskip-unused-source @opindex fskip-unused-source Skip declarations in the input files that aren't actually needed. This flag doesn't change the meaning of correct source code, but it can suppress diagnostics about incorrect source code and suppress output of debugging information for the parts of the input that are skipped. @c APPLE LOCAL end jet @item -fstats @opindex fstats Emit statistics about front-end processing at the end of the compilation. This information is generally only useful to the G++ development team. @item -ftemplate-depth-@var{n} @opindex ftemplate-depth Set the maximum instantiation depth for template classes to @var{n}. A limit on the template instantiation depth is needed to detect endless recursions during template class instantiation. ANSI/ISO C++ conforming programs must not rely on a maximum depth greater than 17. @item -fuse-cxa-atexit @opindex fuse-cxa-atexit Register destructors for objects with static storage duration with the @code{__cxa_atexit} function rather than the @code{atexit} function. This option is required for fully standards-compliant handling of static destructors, but will only work if your C library supports @code{__cxa_atexit}. @c APPLE LOCAL manual This option is not supported on Mac OS X. @item -fvtable-gc @opindex fvtable-gc Emit special relocations for vtables and virtual function references so that the linker can identify unused virtual functions and zero out vtable slots that refer to them. This is most useful with @option{-ffunction-sections} and @option{-Wl,--gc-sections}, in order to also discard the functions themselves. This optimization requires GNU as and GNU ld. Not all systems support this option. @option{-Wl,--gc-sections} is ignored without @option{-static}. @item -fno-weak @opindex fno-weak Do not use weak symbol support, even if it is provided by the linker. By default, G++ will use weak symbols if they are available. This option exists only for testing, and should not be used by end-users; it will result in inferior code and has no benefits. This option may be removed in a future release of G++. @item -nostdinc++ @opindex nostdinc++ Do not search for header files in the standard directories specific to C++, but do still search the other standard directories. (This option is used when building the C++ library.) @end table In addition, these optimization, warning, and code generation options have meanings only for C++ programs: @table @gcctabopt @item -fno-default-inline @opindex fno-default-inline Do not assume @samp{inline} for functions defined inside a class scope. @xref{Optimize Options,,Options That Control Optimization}. Note that these functions will have linkage like inline functions; they just won't be inlined by default. @item -Wabi @r{(C++ only)} @opindex Wabi Warn when G++ generates code that is probably not compatible with the vendor-neutral C++ ABI. Although an effort has been made to warn about all such cases, there are probably some cases that are not warned about, even though G++ is generating incompatible code. There may also be cases where warnings are emitted even though the code that is generated will be compatible. You should rewrite your code to avoid these warnings if you are concerned about the fact that code generated by G++ may not be binary compatible with code generated by other compilers. The known incompatibilities at this point include: @itemize @bullet @item Incorrect handling of tail-padding for bit-fields. G++ may attempt to pack data into the same byte as a base class. For example: @smallexample struct A @{ virtual void f(); int f1 : 1; @}; struct B : public A @{ int f2 : 1; @}; @end smallexample @noindent In this case, G++ will place @code{B::f2} into the same byte as@code{A::f1}; other compilers will not. You can avoid this problem by explicitly padding @code{A} so that its size is a multiple of the byte size on your platform; that will cause G++ and other compilers to layout @code{B} identically. @item Incorrect handling of tail-padding for virtual bases. G++ does not use tail padding when laying out virtual bases. For example: @smallexample struct A @{ virtual void f(); char c1; @}; struct B @{ B(); char c2; @}; struct C : public A, public virtual B @{@}; @end smallexample @noindent In this case, G++ will not place @code{B} into the tail-padding for @code{A}; other compilers will. You can avoid this problem by explicitly padding @code{A} so that its size is a multiple of its alignment (ignoring virtual base classes); that will cause G++ and other compilers to layout @code{C} identically. @item Incorrect handling of bit-fields with declared widths greater than that of their underlying types, when the bit-fields appear in a union. For example: @smallexample union U @{ int i : 4096; @}; @end smallexample @noindent Assuming that an @code{int} does not have 4096 bits, G++ will make the union too small by the number of bits in an @code{int}. @item Empty classes can be placed at incorrect offsets. For example: @smallexample struct A @{@}; struct B @{ A a; virtual void f (); @}; struct C : public B, public A @{@}; @end smallexample @noindent G++ will place the @code{A} base class of @code{C} at a nonzero offset; it should be placed at offset zero. G++ mistakenly believes that the @code{A} data member of @code{B} is already at offset zero. @item Names of template functions whose types involve @code{typename} or template template parameters can be mangled incorrectly. @smallexample template void f(typename Q::X) @{@} template