⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 invoke.texi

📁 GCC
💻 TEXI
📖 第 1 页 / 共 5 页
字号:
@c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
@c 2000, 2001 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 Free Software Foundation, Inc.

Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be included in translations
approved by the Free Software Foundation instead of in the original
English.
@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 man end
@c man begin SEEALSO
cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(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
For instructions on reporting bugs, see
@w{@uref{http://gcc.gnu.org/bugs.html}}.  Use of the @command{gccbug}
script to report bugs is recommended.
@c man end
@c man begin AUTHOR
See the Info entry for @file{gcc}, or
@w{@uref{http://gcc.gnu.org/thanks.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++.
* 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.
* 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.
* 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
-v  --target-help  --help}

@item C Language Options
@xref{C Dialect Options,,Options Controlling C Dialect}.
@gccoptlist{
-ansi  -std=@var{standard}  -aux-info @var{filename} @gol
-fno-asm  -fno-builtin @gol
-fhosted  -ffreestanding @gol
-trigraphs  -traditional  -traditional-cpp @gol
-fallow-single-precision  -fcond-mismatch @gol
-fsigned-bitfields  -fsigned-char @gol
-funsigned-bitfields  -funsigned-char @gol
-fwritable-strings  -fshort-wchar}

@item C++ Language Options
@xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
@gccoptlist{
-fno-access-control  -fcheck-new  -fconserve-space @gol
-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  -fno-honor-std @gol
-fno-implicit-templates @gol
-fno-implicit-inline-templates @gol
-fno-implement-inlines  -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  -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
-fgnu-runtime  -fnext-runtime  -gen-decls @gol
-Wno-protocol  -Wselector}

@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  -Wdisabled-optimization -Werror @gol
-Wfloat-equal  -Wformat  -Wformat=2 @gol
-Wformat-nonliteral  -Wformat-security @gol
-Wid-clash-@var{len}  -Wimplicit -Wimplicit-int @gol
-Wimplicit-function-declaration @gol
-Werror-implicit-function-declaration @gol
-Wimport  -Winline @gol
-Wlarger-than-@var{len}  -Wlong-long @gol
-Wmain  -Wmissing-braces  -Wmissing-declarations @gol
-Wmissing-format-attribute  -Wmissing-noreturn @gol
-Wmultichar  -Wno-format-extra-args -Wno-format-y2k @gol
-Wno-import  -Wpacked  -Wpadded @gol
-Wparentheses  -Wpointer-arith  -Wredundant-decls @gol
-Wreturn-type  -Wsequence-point  -Wshadow @gol
-Wsign-compare  -Wswitch  -Wsystem-headers @gol
-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-prototypes  -Wnested-externs @gol
-Wstrict-prototypes  -Wtraditional}

@item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@gccoptlist{
-a  -ax  -d@var{letters}  -dumpspecs  -dumpmachine  -dumpversion @gol
-fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol
-fdump-ast-original@r{[}-@var{n}@r{]} -fdump-ast-optimized@r{[}-@var{n}@r{]} @gol
-fmem-report  -fpretend-float @gol
-fprofile-arcs  -ftest-coverage  -ftime-report @gol
-g  -g@var{level}  -gcoff  -gdwarf  -gdwarf-1  -gdwarf-1+  -gdwarf-2 @gol
-ggdb  -gstabs  -gstabs+  -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
-save-temps  -time}

@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
-fbranch-probabilities  -fcaller-saves @gol
-fcse-follow-jumps  -fcse-skip-blocks  -fdata-sections  -fdce @gol
-fdelayed-branch  -fdelete-null-pointer-checks @gol
-fexpensive-optimizations  -ffast-math  -ffloat-store @gol
-fforce-addr  -fforce-mem  -ffunction-sections  -fgcse  @gol
-finline-functions  -finline-limit=@var{n}  -fkeep-inline-functions @gol
-fkeep-static-consts  -fmove-all-movables @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
-fomit-frame-pointer  -foptimize-register-move @gol
-foptimize-sibling-calls  -freduce-all-givs @gol
-fregmove  -frename-registers @gol
-frerun-cse-after-loop  -frerun-loop-opt @gol
-fschedule-insns  -fschedule-insns2 @gol
-fsingle-precision-constant  -fssa @gol
-fstrength-reduce  -fstrict-aliasing  -fthread-jumps  -ftrapv @gol
-funroll-all-loops  -funroll-loops  @gol
--param @var{name}=@var{value}
-O  -O0  -O1  -O2  -O3  -Os}

@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
-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
-nostartfiles  -nodefaultlibs  -nostdlib @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-  -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{
-b @var{machine}  -V @var{version}}

@item Machine Dependent Options
@xref{Submodel Options,,Hardware Models and Configurations}.
@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 @gol
-mauto-incdec  -mshort  -msoft-reg-count=@var{count}}

@emph{VAX Options}
@gccoptlist{
-mg  -mgnu  -munix}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -