gcc手册(中文版)

GCC 中文手册(上)

--------------------------------------------------------------------------------
来源:CSDN 作者:ruixj 发布时间:2007-7-17 人气:216



使用gcc -v --help可以列出gcc的所有可选项

Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Usage: gcc [options] file...
Options:
-pass-exit-codes Exit with highest error code from a phase
--help Display this information
--target-help Display target specific command line options
-dumpspecs Display all of the built in spec strings
-dumpversion Display the version of the compiler
-dumpmachine Display the compiler's target processor
-print-search-dirs Display the directories in the compiler's search path
-print-libgcc-file-name Display the name of the compiler's companion library
-print-file-name= Display the full path to library
-print-prog-name= Display the full path to compiler component
-print-multi-directory Display the root directory for versions of libgcc
-print-multi-lib Display the mapping between command line options and
multiple library search directories
-print-multi-os-directory Display the relative path to OS libraries
-Wa, Pass comma-separated on to the assembler
-Wp, Pass comma-separated on to the divprocessor
-Wl, Pass comma-separated on to the linker
-Xassembler Pass on to the assembler
-Xdivprocessor Pass on to the divprocessor
-Xlinker Pass on to the linker
-save-temps Do not delete intermediate files
-pipe Use pipes rather than intermediate files
-time Time the execution of each subprocess
-specs= Override built-in specs with the contents of
-std= Assume that the input sources are for
-B Add to the compiler's search paths
-b Run gcc for target , if installed
-V Run gcc version number , if installed
-v Display the programs invoked by the compiler
-### Like -v but options quoted and commands not executed
-E Preprocess only; do not compile, assemble or link
-S Compile only; do not assemble or link
-c Compile and assemble, but do not link
-o Place the output into
-x Specify the language of the following input files
Permissible languages include: c c++ assembler none
'none' means revert to the default behavior of

guessing the language based on the file's extension

Options starting with -g, -f, -m, -O, -W, or --param are automatically
passed on to the various sub-processes invoked by gcc. In order to pass
other options on to these processes the -W options must be used.
Configured with: ../configure --divfix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)

/usr/libexec/gcc/x86_64-redhat-linux/3.4.6/cc1 -quiet -v help-dummy -quiet -dumpbase help-dummy -mtune=k8 -auxbase help-dummy -version --help -o /tmp/cc0yUXP4.s

The following options are language-independent:

--help Display this information
--param = Set parameter to value. See below for a complete list of parameters
--target-help This switch lacks documentation
--version This switch lacks documentation
-G Put global and static data smaller than bytes into a special section (on some targets)
-O Set optimization level to
-Os Optimize for space rather than speed
-W This switch is dedivcated; use -Wextra instead
-Waggregate-return Warn about returning structures, unions or arrays
-Wcast-align Warn about pointer casts which increase alignment
-Wdedivcated-declarations Warn about uses of __attribute__((dedivcated)) declarations
-Wdisabled-optimization Warn when an optimization pass is disabled
-Werror Treat all warnings as errors
-Wextra Print extra (possibly unwanted) warnings
-Winline Warn when an inlined function cannot be inlined
-Wlarger-than- Warn if an object is larger than bytes
-Wmissing-noreturn Warn about functions which might be candidates for __attribute__((noreturn))
-Wpacked Warn when the packed attribute has no effect on struct layout
-Wpadded Warn when padding is required to align structure members
-Wshadow Warn when one local variable shadows another
-Wstrict-aliasing Warn about code which might break strict aliasing rules
-Wswitch Warn about enumerated switches, with no default, missing a case
-Wswitch-default Warn about enumerated switches missing a "default:" statement
-Wswitch-enum Warn about all enumerated switches missing a specific case
-Wsystem-headers Do not supdivss warnings from system headers
-Wuninitialized Warn about uninitialized automatic variables
-Wunrea

chable-code Warn about code that will never be executed
-Wunused Enable all -Wunused- warnings
-Wunused-function Warn when a function is unused
-Wunused-label Warn when a label is unused
-Wunused-parameter Warn when a function parameter is unused
-Wunused-value Warn when an exdivssion value is unused
-Wunused-variable Warn when a variable is unused
-aux-info Emit declaration information into
-aux-info= This switch lacks documentation
-auxbase This switch lacks documentation
-auxbase-strip This switch lacks documentation
-d Enable dumps from specific passes of the compiler
-dumpbase Set the file basename to be used for dumps
-fPIC This switch lacks documentation
-fPIE This switch lacks documentation
-fabi-version= This switch lacks documentation
-falign-functions Align the start of functions
-falign-functions= This switch lacks documentation
-falign-jumps Align labels which are only reached by jumping
-falign-jumps= This switch lacks documentation
-falign-labels Align all labels
-falign-labels= This switch lacks documentation
-falign-loops Align the start of loops
-falign-loops= This switch lacks documentation
-fargument-alias Specify that arguments may alias each other and globals
-fargument-noalias Assume arguments may alias globals but not each other
-fargument-noalias-global Assume arguments alias neither each other nor globals
-fasynchronous-unwind-tables Generate unwind tables that are exact at each instruction boundary
-fbounds-check Generate code to check bounds before indexing arrays
-fbranch-count-reg Replace add, compare, branch with branch on count register
-fbranch-probabilities Use profiling information for branch probabilities
-fbranch-target-load-optimize Perform branch target load optimization before prologue / epilogue threading
-fbranch-target-load-optimize2 Perform branch target load optimization after prologue / epilogue threading
-fcall-saved- Mark as being divserved across functions
-fcall-used- Mark as being corrupted by function calls
-fcaller-saves Save registers around function calls
-fcommon Do not put uninitialized globals in the common section
-fcprop-registers Perform a register copy-propagation optimization pass
-fcrossjumping Perform cross-jumping optimization
-fcse-follow-jumps When running CSE, follow jumps to their targets
-fcse-skip-blocks When running CSE, follow conditiona

l jumps
-fdata-sections Place data items into their own section
-fdefer-pop Defer popping functions args from stack until later
-fdelayed-branch Attempt to fill delay slots of branch instructions
-fdelete-null-pointer-checks Delete useless null pointer checks
-fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped
diagnostics
-fdump-unnumbered Supdivss output of instruction numbers and line number notes in debugging dumps
-feliminate-dwarf2-dups Perform DWARF2 duplicate elimination
-feliminate-unused-debug-symbols Perform unused type elimination in debug info
-feliminate-unused-debug-types Perform unused type elimination in debug info
-fexceptions Enable exception handling
-fexpensive-optimizations Perform a number of minor, expensive optimizations
-ffast-math This switch lacks documentation
-ffinite-math-only Assume no NaNs or infinities are generated
-ffixed- Mark as being unavailable to the compiler
-ffloat-store Do not store floats in registers
-fforce-addr Copy memory address constants into registers before use
-fforce-mem Copy memory operands into registers before use
-fframe-base-loclist Allow use of DWARF2 location lists for frame base
-ffunction-cse Allow function addresses to be held in registers
-ffunction-sections Place each function into its own section
-fgcse Perform global common subexdivssion elimination
-fgcse-las Perform redundant load after store elimination in global common subexdivssion elimination
-fgcse-lm Perform enhanced load motion during global common subexdivssion elimination
-fgcse-sm Perform store motion after global common subexdivssion elimination
-fguess-branch-probability Enable guessing of branch probabilities
-fident Process #ident directives
-fif-conversion Perform conversion of conditional jumps to branchless equivalents
-fif-conversion2 Perform conversion of conditional jumps to conditional execution
-finhibit-size-directive Do not generate .size directives
-finline Pay attention to the "inline" keyword
-finline-functions This switch lacks documentation
-finline-limit- This switch lacks documentation
-finline-limit= Limit the size of inlined functions to
-finstrument-functions Instrument function entry and exit with profiling calls
-fkeep-inline-functions Generate code for functions even if they are fully inlined
-fkeep-static-consts Emit static const variables even if they are not used
-fleading-underscore Give exter

nal symbols a leading underscore
-floop-optimize Perform loop optimizations
-fmath-errno Set errno after built-in math functions
-fmem-report Report on permanent memory allocation
-fmerge-all-constants Attempt to merge identical constants and constant variables
-fmerge-constants Attempt to merge identical constants across compilation units
-fmessage-length= Limit diagnostics to characters per line. 0 supdivsses line-wrapping
-fmove-all-movables Force all loop invariant computations out of loops
-fnew-ra Use graph-coloring register allocation
-fnon-call-exceptions Support synchronous non-call exceptions
-fold-unroll-all-loops Perform loop unrolling for all loops
-fold-unroll-loops Perform loop unrolling when iteration count is known
-fomit-frame-pointer When possible do not generate stack frames
-foptimize-register-move Do the full register move optimization pass
-foptimize-sibling-calls Optimize sibling and tail recursive calls
-fpack-struct Pack structure members together without holes
-fpcc-struct-return Return small aggregates in memory, not registers
-fpeel-loops Perform loop peeling
-fpeephole Enable machine specific peephole optimizations
-fpeephole2 Enable an RTL peephole pass before sched2
-fpic Generate position-independent code if possible
-fpie Generate position-independent code for executables if possible
-fdivfetch-loop-arrays Generate divfetch instructions, if available, for arrays in loops
-fprofile Enable basic program profiling code
-fprofile-arcs Insert arc-based program profiling code
-fprofile-generate Enable common options for generating profile info for profile feedback directed optimizations
-fprofile-use Enable common options for performing profile feedback directed optimizations
-fprofile-values Insert code to profile values of exdivssions
-frandom-seed This switch lacks documentation
-frandom-seed= Make compile reproducible using
-freduce-all-givs Strength reduce all loop general induction variables
-freg-struct-return Return small aggregates in registers
-fregmove Enables a register move optimization
-frename-registers Perform a register renaming optimization pass
-freorder-blocks Reorder basic blocks to improve code placement
-freorder-functions Reorder functions to improve code placement
-frerun-cse-after-loop Add a common subexdivssion elimination pass after loop optimizations
-frerun-loop-opt Run the loop optimizer twice
-frounding-math Disable optimizations that

assume default FP rounding behavior
-fsched-interblock Enable scheduling across basic blocks
-fsched-spec Allow speculative motion of non-loads
-fsched-spec-load Allow speculative motion of some loads
-fsched-spec-load-dangerous Allow speculative motion of more loads
-fsched-stalled-insns Allow divmature scheduling of queued insns
-fsched-stalled-insns-dep Set dependence distance checking in divmature scheduling of queued insns
-fsched-stalled-insns-dep= -fsched-stalled-insns-dep= Set dependence distance checking in divmature scheduling
of queued insns
-fsched-stalled-insns= -fsched-stalled-insns= Set number of queued insns that can be divmaturely
scheduled
-fsched-verbose= Set the verbosity level of the scheduler
-fsched2-use-superblocks If scheduling post reload, do superblock scheduling
-fsched2-use-traces If scheduling post reload, do trace scheduling
-fschedule-insns Reschedule instructions before register allocation
-fschedule-insns2 Reschedule instructions after register allocation
-fshared-data Mark data as shared rather than private
-fsignaling-nans Disable optimizations observable by IEEE signaling NaNs
-fsingle-divcision-constant Convert floating point constants to single divcision constants
-fstack-check Insert stack checking code into the program
-fstack-limit This switch lacks documentation
-fstack-limit-register= Trap if the stack goes past
-fstack-limit-symbol= Trap if the stack goes past symbol
-fstrength-reduce Perform strength reduction optimizations
-fstrict-aliasing Assume strict aliasing rules apply
-fsyntax-only Check for syntax errors, then stop
-ftest-coverage Create data files needed by "gcov"
-fthread-jumps Perform jump threading optimizations
-ftime-report Report the time taken by each compiler pass
-ftls-model=[global-dynamic|local-dynamic|initial-exec|local-exec] Set the default thread-local storage code generation
model
-ftracer Perform superblock formation via tail duplication
-ftrapping-math Assume floating-point operations can trap
-ftrapv Trap for signed overflow in addition, subtraction and multiplication
-funit-at-a-time Compile whole compilation unit at a time
-funroll-all-loops Perform loop unrolling for all loops
-funroll-loops Perform loop unrolling when iteration count is known
-funsafe-math-optimizations Allow math optimizations that may violate IEEE or ISO standards
-funswitch-loops Perform loop unswitching
-funwind-tables Just ge

nerate unwind tables for exception handling
-fvar-tracking Perform variable tracking
-fverbose-asm Add extra commentary to assembler output
-fvisibility=[default|internal|hidden|protected] Set the default symbol visibility
-fvpt Use exdivssion value profiles in optimizations
-fweb Construct webs and split unrelated uses of single variable
-fwrapv Assume signed arithmetic overflow wraps around
-fwritable-strings Store strings in writable data section
-fzero-initialized-in-bss Put zero initialized data in the bss section
-g Generate debug information in default format
-gcoff Generate debug information in COFF format
-gdwarf-2 Generate debug information in DWARF v2 format
-ggdb Generate debug information in default extended format
-gstabs Generate debug information in STABS format
-gstabs+ Generate debug information in extended STABS format
-gvms Generate debug information in VMS format
-gxcoff Generate debug information in XCOFF format
-gxcoff+ Generate debug information in extended XCOFF format
-m This switch lacks documentation
-o Place output into
-p Enable function profiling
-pedantic Issue warnings needed for strict compliance to the standard
-pedantic-errors Like -pedantic but issue them as errors
-quiet Do not display functions compiled or elapsed time
-version This switch lacks documentation
-w Supdivss warnings

The --param option recognizes the following as parameters:

max-inline-insns-single The maximum number of instructions in a single function eligible for inlining
max-inline-insns-auto The maximum number of instructions when automatically inlining
max-inline-insns-rtl The maximum number of instructions for the RTL inliner
max-delay-slot-insn-search The maximum number of instructions to consider to fill a delay slot
max-delay-slot-live-search The maximum number of instructions to consider to find accurate live register information
max-pending-list-length The maximum length of scheduling's pending operations list
large-function-insns The size of function body to be considered large
large-function-growth Maximal growth due to inlining of large function (in percent)
inline-unit-growth how much can given compilation unit grow because of the inlining (in percent)
max-gcse-memory The maximum amount of memory to be allocated by GCSE
max-gcse-passes The maximum number of passes to make when doing GCSE
max

-unrolled-insns The maximum number of instructions to consider to unroll in a loop
max-average-unrolled-insns The maximum number of instructions to consider to unroll in a loop on average
max-unroll-times The maximum number of unrollings of a single loop
max-peeled-insns The maximum number of insns of a peeled loop
max-peel-times The maximum number of peelings of a single loop
max-completely-peeled-insns The maximum number of insns of a completely peeled loop
max-completely-peel-times The maximum number of peelings of a single loop that is peeled completely
max-once-peeled-insns The maximum number of insns of a peeled loop that rolls only once
max-unswitch-insns The maximum number of insns of an unswitched loop
max-unswitch-level The maximum number of unswitchings in a single loop
hot-bb-count-fraction Select fraction of the maximal count of repetitions of basic block in program given basic
block needs to have to be considered hot
hot-bb-frequency-fraction Select fraction of the maximal frequency of executions of basic block in function given basic
block needs to have to be considered hot
tracer-dynamic-coverage-feedback The percentage of function, weighted by execution frequency, that must be covered by
trace formation. Used when profile feedback is available
tracer-dynamic-coverage The percentage of function, weighted by execution frequency, that must be covered by trace
formation. Used when profile feedback is not available
tracer-max-code-growth Maximal code growth caused by tail duplication (in percent)
tracer-min-branch-ratio Stop reverse growth if the reverse probability of best edge is less than this threshold (in
percent)
tracer-min-branch-probability-feedback Stop forward growth if the probability of best edge is less than this threshold (in
percent). Used when profile feedback is available
tracer-min-branch-probability Stop forward growth if the probability of best edge is less than this threshold (in
percent). Used when profile feedback is not available
max-crossjump-edges The maximum number of incoming edges to consider for crossjumping
max-cse-path-length The maximum length of path considered in cse
max-cselib-memory-locations The maximum memory locations recorded by cselib
max-last-value-rtl The maximum number of RTL nodes that can be recorded as combiner's last value
ggc-min-expand Minimum heap expansion to trigger garbage collection, as a percentage of the total size of the
heap
ggc-min-heapsize Minimum heap size before we start collecting garbage, in kilobytes
max-reload-searc

h-insns The maximum number of instructions to search backward when looking for equivalent reload
min-divtend-dynamic-size The minimum size for an auto object to allocate it in the stack as if its size was dynamic

The Ada front end recognizes the following options:

-I This switch lacks documentation
-Wall This switch lacks documentation
-Wlong-long Do not warn about using "long long" when -pedantic
-Wmissing-prototypes Warn about global functions without prototypes
-Wstrict-prototypes Warn about unprototyped function declarations
-Wwrite-strings Give strings the type "array of char"
-fRTS This switch lacks documentation
-gnat Specify options to GNAT
-nostdinc Do not search standard system include directories (those specified with -isystem will still be
used)
-nostdlib This switch lacks documentation


The C front end recognizes the following options:

-I, -Wall, -Wlong-long, -Wmissing-prototypes, -Wstrict-prototypes, -Wwrite-strings, -nostdinc

--output-pch= This switch lacks documentation
-A= Assert the to . Putting '-' before disables the to

-C Do not discard comments
-CC Do not discard comments in macro expansions
-D[=] Define a with as its value. If just is given, is taken to be 1
-H Print the name of header files as they are used
-M This switch lacks documentation
-MD Generate make dependencies and compile
-MF This switch lacks documentation
-MG Treat missing header files as generated files
-MM This switch lacks documentation
-MMD Like -MD but ignore system header files
-MP This switch lacks documentation
-MQ Add a MAKE-quoted target
-MT This switch lacks documentation
-P Do not generate #line directives
-U Undefine
-Wbad-function-cast Warn about casting functions to incompatible types
-Wcast-qual Warn about casts which discard qualifiers
-Wchar-subscripts Warn about subscripts whose type is "char"
-Wcomment This switch lacks documentation
-Wcomments This switch lacks documentation
-Wconversion Warn about possibly confusing type conversions
-Wdeclaration-after-statement Warn when a declaration is found after a statement
-Wdi

v-by-zero Warn about compile-time integer division by zero
-Wendif-labels Warn about stray tokens after #elif and #endif
-Werror-implicit-function-declaration Make implicit function declarations an error
-Wfloat-equal Warn if testing floating point numbers for equality
-Wformat Warn about printf/scanf/strftime/strfmon format string anomalies
-Wformat-extra-args Warn if passing too many arguments to a function for its format string
-Wformat-nonliteral Warn about format strings that are not literals
-Wformat-security Warn about possible security problems with format functions
-Wformat-y2k Warn about strftime formats yielding 2-digit years
-Wformat-zero-length This switch lacks documentation
-Wformat= This switch lacks documentation
-Wimplicit This switch lacks documentation
-Wimplicit-function-declaration Warn about implicit function declarations
-Wimplicit-int Warn when a declaration does not specify a type
-Wimport This switch lacks documentation
-Winit-self Warn about variables which are initialized to themselves.
-Winvalid-pch Warn about PCH files that are found but not used
-Wmain Warn about suspicious declarations of "main"
-Wmissing-braces Warn about possibly missing braces around initializers
-Wmissing-declarations Warn about global functions without divvious declarations
-Wmissing-format-attribute Warn about functions which might be candidates for format attributes
-Wmultichar Warn about use of multi-character character constants
-Wnested-externs Warn about "extern" declarations not at file scope
-Wnonnull This switch lacks documentation
-Wold-style-definition Warn if an old-style parameter definition is used
-Wparentheses Warn about possibly missing parentheses
-Wpointer-arith Warn about function pointer arithmetic
-Wredundant-decls Warn about multiple declarations of the same object
-Wreturn-type Warn whenever a function's return type defaults to "int" (C), or about inconsistent return
types (C++)
-Wsequence-point Warn about possible violations of sequence point rules
-Wsign-compare Warn about signed-unsigned comparisons
-Wtraditional Warn about features not divsent in traditional C
-Wtrigraphs This switch lacks documentation
-Wundef Warn if an undefined macro is used in an #if directive
-Wunknown-pragmas Warn about unrecognized pragmas
-Wunused-macros Warn about macros defined in the main file that are not used
-ansi A synonym for -std=c89 (for C)

or -std=c++98 (for C++).
-fasm Recognize the "asm" keyword
-fbuiltin Recognize built-in functions
-fbuiltin- This switch lacks documentation
-fcond-mismatch Allow the arguments of the '?' operator to have different types
-fdollars-in-identifiers Permit '$' as an identifier character
-fdump- This switch lacks documentation
-fexec-charset= Convert all strings and character constants to character set
-ffixed-form This switch lacks documentation
ffixed-line-length- Set the maximum line length to
-ffreestanding Do not assume that standard C libraries and "main" exist
-fhosted Assume normal C execution environment
-finput-charset= -finput-charset= Specify the default character set for source files.
-fms-extensions Don't warn about uses of Microsoft extensions
-fpch-deps This switch lacks documentation
-fdivprocessed This switch lacks documentation
-fshort-double Use the same size for double as for float
-fshort-enums Use the narrowest integer type possible for enumeration types
-fshort-wchar Force the underlying type for "wchar_t" to be "unsigned short"
-fshow-column This switch lacks documentation
-fsigned-bitfields When "signed" or "unsigned" is not given make the bitfield signed
-fsigned-char Make "char" signed by default
-ftabstop= Distance between tab stops for column reporting
-funsigned-bitfields When "signed" or "unsigned" is not given make the bitfield unsigned
-funsigned-char Make "char" unsigned by default
-fwide-exec-charset= Convert all wide strings and character constants to character set
-fworking-directory Generate a #line directive pointing at the current working directory
-idirafter

Add to the end of the system include path
-imacros Accept definition of macros in
-include Include the contents of before other files
-idivfix Specify as a divfix for next two options
-isysroot Set to be the system root directory
-isystem Add to the start of the system include path
-iwithdivfix Add to the end of the system include path
-iwithdivfixbefore Add to the end of the main include path
-remap Remap file names when including files
-std=c89 Conform to the ISO 1990 C standard
-std=c99 Conform to the ISO 1999 C standard
-std=c9x Dedivcated in favor of -std=c99
-std=gnu89 Conform to the ISO 1990

C standard with GNU extensions
-std=gnu99 Conform to the ISO 1999 C standard with GNU extensions
-std=gnu9x Dedivcated in favor of -std=gnu99
-std=iso9899:1990 Conform to the ISO 1990 C standard
-std=iso9899:199409 Conform to the ISO 1990 C standard as amended in 1994
-std=iso9899:1999 Conform to the ISO 1999 C standard
-std=iso9899:199x Dedivcated in favor of -std=iso9899:1999
-traditional-cpp Enable traditional divprocessing
-trigraphs Support ISO C trigraphs
-undef Do not divdefine system-specific and GCC-specific macros
-v Enable verbose output

The C++ front end recognizes the following options:

--output-pch=, -A, -C, -CC, -D, -H, -I, -M, -MD, -MF, -MG, -MM, -MMD, -MP, -MQ, -MT, -P, -U, -Wall, -Wcast-qual,
-Wchar-subscripts, -Wcomment, -Wcomments, -Wconversion, -Wendif-labels, -Wfloat-equal, -Wformat, -Wformat-extra-args,
-Wformat-nonliteral, -Wformat-security, -Wformat-y2k, -Wformat=, -Wimplicit, -Wimport, -Winit-self, -Winvalid-pch,
-Wlong-long, -Wmissing-braces, -Wmissing-format-attribute, -Wmultichar, -Wparentheses, -Wpointer-arith, -Wredundant-decls,
-Wreturn-type, -Wsign-compare, -Wtrigraphs, -Wundef, -Wunknown-pragmas, -Wunused-macros, -Wwrite-strings, -ansi, -fasm,
-fbuiltin, -fbuiltin-, -fcond-mismatch, -fdollars-in-identifiers, -fdump-, -fexec-charset=, -finput-charset=,
-fms-extensions, -fpch-deps, -fdivprocessed, -fshort-double, -fshort-enums, -fshort-wchar, -fshow-column,
-fsigned-bitfields, -fsigned-char, -ftabstop=, -funsigned-bitfields, -funsigned-char, -fwide-exec-charset=,
-fworking-directory, -idirafter, -imacros, -include, -idivfix, -isysroot, -isystem, -iwithdivfix, -iwithdivfixbefore,
-nostdinc, -remap, -traditional-cpp, -trigraphs, -undef, -v

-Wabi This switch lacks documentation
-Wctor-dtor-privacy Warn when all constructors and destructors are private
-Wdedivcated Warn if dedivcated class, method, or field is used
-Weffc++ Warn about violations of Effective C++ style rules
-Winvalid-offsetof Warn about invalid uses of the "offsetof" macro
-Wnon-template-friend Warn when non-templatized friend functions are declared within a template
-Wnon-virtual-dtor Warn about non-virtual destructors
-Wold-style-cast Warn if a C-style cast is used in a program
-Woverloaded-virtual Warn about overloaded virtual function names
-Wpmf-conversions Warn when converting the type of pointers to member functions
-Wreorder Warn when the compiler reorders code
-Wsign-promo Warn when overload promotes from unsigned to signed
-Wsynth Warn when synthesis behavior differs from Cfront
-faccess-control Enforce class me

mber access control semantics
-fall-virtual This switch lacks documentation
-falt-external-templates Change when template instances are emitted
-fcheck-new Check the return value of new
-fconserve-space Reduce the size of object files
-fconst-strings Make string literals "const char[]" not "char[]"
-fdefault-inline Inline member functions by default
-felide-constructors This switch lacks documentation
-fenforce-eh-specs Generate code to check exception specifications
-fenum-int-equiv This switch lacks documentation
-fexternal-templates This switch lacks documentation
-ffor-scope Scope of for-init-statement variables is local to the loop
-fgnu-keywords Recognize GNU-defined keywords
-fguiding-decls This switch lacks documentation
-fhandle-exceptions This switch lacks documentation
-fhonor-std This switch lacks documentation
-fhuge-objects Enable support for huge objects
-fimplement-inlines Export functions even if they can be inlined
-fimplicit-inline-templates Emit implicit instantiations of inline templates
-fimplicit-templates Emit implicit instantiations of templates
-flabels-ok This switch lacks documentation
-fname-mangling-version- This switch lacks documentation
-fnew-abi This switch lacks documentation
-fnonansi-builtins This switch lacks documentation
-fnonnull-objects This switch lacks documentation
-foperator-names Recognize C++ kewords like "compl" and "xor"
-foptional-diags Enable optional diagnostics
-fpermissive Downgrade conformance errors to warnings
-frepo Enable automatic template instantiation
-frtti Generate run time type descriptor information
-fsquangle This switch lacks documentation
-fstats Display statistics accumulated during compilation
-fstrict-prototype This switch lacks documentation
-ftemplate-depth- Specify maximum template instantiation depth
-fthis-is-variable This switch lacks documentation
-fno-threadsafe-statics Do not generate thread-safe code for initializing local statics.
-fuse-cxa-atexit Use __cxa_atexit to register destructors
-fvisibility-inlines-hidden Marks all inlined methods as having hidden visibility
-fvtable-gc Discard unused virtual functions
-fvtable-thunks Implement vtables using thunks
-fweak Emit common-like symbols as weak symbols
-fxref Emit cross referencing information
-nostdinc++ Do not search standard system include directories for C++
-std=c++98 Conform t

o the ISO 1998 C++ standard
-std=gnu++98 Conform to the ISO 1998 C++ standard with GNU extensions

Target specific options:
-mno-tls-direct-seg-refs Do not use direct references against %gs when accessing tls data
-mtls-direct-seg-refs Use direct references against %gs when accessing tls data
-mno-red-zone Do not use red-zone in the x86-64 code
-mred-zone Use red-zone in the x86-64 code
-mno-ms-bitfields Use gcc default bitfield layout
-mms-bitfields Use native (MS) bitfield layout
-m32 Generate 32bit i386 code
-m64 Generate 64bit x86-64 code
-m96bit-long-double sizeof(long double) is 12
-m128bit-long-double sizeof(long double) is 16
-mno-sse3 Do not support MMX, SSE, SSE2 and SSE3 built-in functions and code generation
-msse3 Support MMX, SSE, SSE2 and SSE3 built-in functions and code generation
-mno-sse2 Do not support MMX, SSE and SSE2 built-in functions and code generation
-msse2 Support MMX, SSE and SSE2 built-in functions and code generation
-mno-sse Do not support MMX and SSE built-in functions and code generation
-msse Support MMX and SSE built-in functions and code generation
-mno-3dnow Do not support 3DNow! built-in functions
-m3dnow Support 3DNow! built-in functions
-mno-mmx Do not support MMX built-in functions
-mmmx Support MMX built-in functions
-mno-accumulate-outgoing-args Do not use push instructions to save outgoing arguments
-maccumulate-outgoing-args Use push instructions to save outgoing arguments
-mno-push-args Do not use push instructions to save outgoing arguments
-mpush-args Use push instructions to save outgoing arguments
-mno-inline-all-stringops Do not inline all known string operations
-minline-all-stringops Inline all known string operations
-mno-align-stringops Do not align destination of the string operations
-malign-stringops Align destination of the string operations
-mstack-arg-probe Enable stack probing
-momit-leaf-frame-pointer Omit the frame pointer in leaf functions
-mfancy-math-387 Generate sin, cos, sqrt for FPU
-mno-fancy-math-387 Do not generate sin, cos, sqrt for FPU
-mno-fp-ret-in-387 Do not return values of functions in FPU registers
-mfp-ret-in-387 Return values of functions in FPU registers
-mno-ieee-fp Do not use IEEE math for fp comparisons
-mieee-fp Use IEEE math for fp comparisons
-mno-svr3-shlib Uninitialized locals in .data
-msvr3-shlib Uninitialized locals in .bss
-mno-align-double Align doubles on word boundary
-malign-double Ali

gn some doubles on dword boundary
-mno-rtd Use normal calling convention
-mrtd Alternate calling convention
-mno-soft-float Use hardware fp
-msoft-float Do not use hardware fp
-mhard-float Use hardware fp
-mno-80387 Do not use hardware fp
-m80387 Use hardware fp
-mtls-dialect= Use given thread-local storage dialect
-masm= Use given assembler dialect
-mcmodel= Use given x86-64 code model
-mbranch-cost= Branches are this expensive (1-5, arbitrary units)
-mdivferred-stack-boundary= Attempt to keep stack aligned to this power of 2
-malign-functions= Function starts are aligned to this power of 2
-malign-jumps= Jump targets are aligned to this power of 2
-malign-loops= Loop code aligned to this power of 2
-mregparm= Number of registers used to pass integer arguments
-march= Generate code for given CPU
-mfpmath= Generate floating point mathematics using given instruction set
-mtune= Schedule code for given CPU








GCC 中文手册(上)


GCC
Section: GNU Tools (1)
Updated: 2003/12/05
Index Return to Main Contents
--------------------------------------------------------------------------------

NAME
gcc,g++-GNU工程的C和C++编译器(egcs-1.1.2)
总览(SYNOPSIS)
gcc[option|filename ]...
g++[option|filename ]...

警告(WARNING)
本手册页内容摘自GNU C编译器的完整文档,仅限于解释选项的含义.
除非有人自愿维护,否则本手册页不再更新.如果发现手册页和软件之间有所矛盾,请查对Info文件, Info文件是权威文档.

如果我们发觉本手册页的内容由于过时而导致明显的混乱和抱怨时,我们就停止发布它.不可能有其他选择,象更新Info文件同时更新man手册,因为其他维护GNU CC的工作没有留给我们时间做这个. GNU工程认为man手册是过时产物,应该把时间用到别的地方.

如果需要完整和最新的文档,请查阅Info文件`gcc'或Using and Porting GNU CC (for version 2.0) (使用和移植GNU CC 2.0) 手册.二者均来自Texinfo原文件 gcc.texinfo.


描述(DESCRIPTION)
C和C++编译器是集成的.他们都要用四个步骤中的一个或多个处理输入文件: 预处理(divprocessing),编译(compilation),汇编(assembly)和连接(linking).源文件后缀名标识源文件的 语言,但是对编译器来说,后缀名控制着缺省设定:
gcc
认为预处理后的文件(.i)是C文件,并且设定C形式的连接.
g++
认为预处理后的文件(.i)是C++文件,并且设定C++形式的连接.
源文件后缀名指出语言种类以及后期的操作:

.c C源程序;预处理,编译,汇编.C C++源程序;预处理,编译,汇编.cc C++源程序;预处理,编

译,汇编.cxx C++源程序;预处理,编译,汇编.m Objective-C源程序;预处理,编译,汇编.i 预处理后的C文件;编译,汇编.ii 预处理后的C++文件;编译,汇编.s 汇编语言源程序;汇编.S 汇编语言源程序;预处理,汇编.h 预处理器文件;通常不出现在命令行上
其他后缀名的文件被传递给连接器(linker).通常包括:
.o 目标文件(Object file).a 归档库文件(Archive file)
除非使用了-c, -S,或-E选项(或者编译错误阻止了完整的过程),否则连接总是 最后的步骤.在连接阶段中,所有对应于源程序的.o文件, -l库文件,无法识别的文件名(包括指定的 .o目标文件和.a库文件)按命令行中的顺序传递给连接器.


选项(OPTIONS)
选项必须分立给出: `-dr'完全不同于`-d -r '.
大多数`-f'和`-W'选项有两个相反的格式: -fname和 -fno-name (或-Wname和-Wno-name).这里 只列举不是默认选项的格式.

下面是所有选项的摘要,按类型分组,解释放在后面的章节中.

总体选项(Overall Option)

-c -S -E -o file -pipe -v -x language
语言选项(Language Option)
-ansi -fall-virtual -fcond-mismatch -fdollars-in-identifiers -fenum-int-equiv -fexternal-templates -fno-asm -fno-builtin -fhosted -fno-hosted -ffreestanding -fno-freestanding -fno-strict-prototype -fsigned-bitfields -fsigned-char -fthis-is-variable -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs
警告选项(Warning Option)
-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment -Wconversion -Wenum-clash -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int -Wimplicit-function-declaration -Winline -Wlong-long -Wmain -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-import -Wparentheses -Wpointer-arith -Wredundant-decls -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wtemplate-debugging -Wtraditional -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings
调试选项(Debugging Option)
-a -dletters -fdivtend-float -g -glevel -gcoff -gxcoff -gxcoff+ -gdwarf -gdwarf+ -gstabs -gstabs+ -ggdb -p -pg -save-temps -print-file-name=library -print-libgcc-file-name -print-prog-name=program
优化选项(Optimization Option)
-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -felide-constructors -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -finline-functions -fkeep-inline-functions -fmemoize-lookups -fno-default-inline -fno-defer-pop -fno-function-cse -fno-inline -fno-peephole -fomit-frame-pointer -frerun-cse-after-loop -fschedule-insns -fschedule-insns2 -fstrength-reduce -fthread-jumps -funroll-all-loops -funroll-loops -O -O2 -O3
预处理器选项(Preprocessor Option)
-Aassertion -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include file -imacros file -idivfix file -iwithdivfix dir -M -MD -MM -MMD -nostdinc -P -Umacro -undef

编器选项(Assembler Option)
-Wa,option
连接器选项(Linker Option)
-llibrary -nostartfiles -nostdlib -static -shared -symbolic -Xlinker option -Wl,option -u symbol
目录选项(Directory Option)
-Bdivfix -Idir -I- -Ldir
目标机选项(Target Option)
-b machine -V version
配置相关选项(Configuration Dependent Option)
M680x0 选项
-m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield -mrtd -mshort -msoft-float
VAX选项
-mg -mgnu -munix

SPARC选项
-mepilogue -mfpu -mhard-float -mno-fpu -mno-epilogue -msoft-float -msparclite -mv8 -msupersparc -mcydivss

Convex选项
-margcount -mc1 -mc2 -mnoargcount

AMD29K选项
-m29000 -m29050 -mbw -mdw -mkernel-registers -mlarge -mnbw -mnodw -msmall -mstack-check -muser-registers

M88K选项
-m88000 -m88100 -m88110 -mbig-pic -mcheck-zero-division -mhandle-large-shift -midentify-revision -mno-check-zero-division -mno-ocs-debug-info -mno-ocs-frame-position -mno-optimize-arg-area -mno-serialize-volatile -mno-underscores -mocs-debug-info -mocs-frame-position -moptimize-arg-area -mserialize-volatile -mshort-data-num -msvr3 -msvr4 -mtrap-large-shift -muse-div-instruction -mversion-03.00 -mwarn-passed-structs

RS6000选项
-mfp-in-toc -mno-fop-in-toc

RT选项
-mcall-lib-mul -mfp-arg-in-fdivgs -mfp-arg-in-gregs -mfull-fp-blocks -mhc-struct-return -min-line-mul -mminimum-fp-blocks -mnohc-struct-return

MIPS选项
-mcpu=cpu type -mips2 -mips3 -mint64 -mlong64 -mmips-as -mgas -mrnames -mno-rnames -mgpopt -mno-gpopt -mstats -mno-stats -mmemcpy -mno-memcpy -mno-mips-tfile -mmips-tfile -msoft-float -mhard-float -mabicalls -mno-abicalls -mhalf-pic -mno-half-pic -G num -nocpp

i386选项
-m486 -mno-486 -msoft-float -mno-fp-ret-in-387

HPPA选项
-mpa-risc-1-0 -mpa-risc-1-1 -mkernel -mshared-libs -mno-shared-libs -mlong-calls -mdisable-fdivgs -mdisable-indexing -mtrailing-colon

i960选项
-mcpu-type -mnumerics -msoft-float -mleaf-procedures -mno-leaf-procedures -mtail-call -mno-tail-call -mcomplex-addr -mno-complex-addr -mcode-align -mno-code-align -mic-compat -mic2.0-compat -mic3.0-compat -masm-compat -mintel-asm -mstrict-align -mno-strict-align -mold-align -mno-old-align

DEC Alpha选项
-mfp-regs -mno-fp-regs -mno-soft-float -msoft-float

System V选项
-G -Qy -Qn -YP,paths -Ym,dir

代码生成选项(Code Generation Option)
-fcall-saved-reg -fcall-used-reg -ffixed-reg -finhibit-size-directive -fnonnull-objects -fno-common -fno-ident -fno-gnu-linker -fpcc-struct-return -fpic -fPIC -freg-struct-return -fshared-data -fshort-enums -fshort-double -fvolatile -fvolatile-global -fverbose-asm

总体选项(Overall Option)
-x language
明确指出后面输入文件的语言为language (而不是从文件名后缀得到的默认选择).这个选项应用于后面 所有的输入文件,直到遇着下一个`-x'选项. language的可选值有`c', `objective-c', `c-header', `c++', `cpp-

output', `assembler',和`assembler-with-cpp'.
-x none
关闭任何对语种的明确说明,因此依据文件名后缀处理后面的文件(就象是从未使用过`-x'选项).
如果只操作四个阶段(预处理,编译,汇编,连接)中的一部分,可以使用`-x'选项(或文件名后缀)告诉 gcc从哪里开始,用`-c', `-S',或`-E'选项告诉gcc到 哪里结束.注意,某些选项组合(例如, `-x cpp-output -E')使gcc不作任何事情.

-c
编译或汇编源文件,但是不作连接.编译器输出对应于源文件的目标文件.
缺省情况下, GCC通过用`.o'替换源文件名后缀`.c', `.i', `.s',等等,产生目标文件名.可以使用-o选项选择其他名字.

GCC忽略-c选项后面任何无法识别的输入文件(他们不需要编译或汇编).

-S
编译后即停止,不进行汇编.对于每个输入的非汇编语言文件,输出文件是汇编语言文件.
缺省情况下, GCC通过用`.o'替换源文件名后缀`.c', `.i',等等,产生 目标文件名.可以使用-o选项选择其他名字.

GCC忽略任何不需要编译的输入文件.

-E
预处理后即停止,不进行编译.预处理后的代码送往标准输出.
GCC忽略任何不需要预处理的输入文件.

-o file
指定输出文件为file.该选项不在乎GCC产生什么输出,无论是可执行文件,目标文件,汇编文件还是 预处理后的C代码.
由于只能指定一个输出文件,因此编译多个输入文件时,使用`-o'选项没有意义,除非输出一个可执行文件.

如果没有使用`-o'选项,默认的输出结果是:可执行文件为`a.out', `source.suffix '的目标文件是`source.o',汇编文件是 `source.s',而预处理后的C源代码送往标准输出.

-v
(在标准错误)显示执行编译阶段的命令.同时显示编译器驱动程序,预处理器,编译器的版本号.
-pipe
在编译过程的不同阶段间使用管道而非临时文件进行通信.这个选项在某些系统上无法工作,因为那些系统的 汇编器不能从管道读取数据. GNU的汇编器没有这个问题.

语言选项(LANGUAGE OPTIONS)
下列选项控制编译器能够接受的C "方言":
-ansi
支持符合ANSI标准的C程序.
这样就会关闭GNU C中某些不兼容ANSI C的特性,例如asm, inline和 typeof关键字,以及诸如unix和vax这些表明当前系统类型的预定义宏.同时开启 不受欢迎和极少使用的ANSI trigraph特性,以及禁止`$'成为标识符的一部分.

尽管使用了`-ansi'选项,下面这些可选的关键字, __asm__, __extension__, __inline__和__typeof__仍然有效.你当然不会把 他们用在ANSI C程序中,但可以把他们放在头文件里,因为编译包含这些头文件的程序时,可能会指定 `-ansi'选项.另外一些预定义宏,如__unix__和__vax__,无论有没有使用 `-ansi'选项,始终有效.

使用`-ansi'选项不会自动拒绝编译非ANSI程序,除非增加`-pedantic'选项作为 `-ansi'选

项的补充.

使用`-ansi'选项的时候,预处理器会预定义一个__STRICT_ANSI__宏.有些头文件 关注此宏,以避免声明某些函数,或者避免定义某些宏,这些函数和宏不被ANSI标准调用;这样就不会干扰在其他地方 使用这些名字的程序了.

-fno-asm
不把asm, inline或typeof当作关键字,因此这些词可以用做标识符.用 __asm__, __inline__和__typeof__能够替代他们. `-ansi' 隐含声明了`-fno-asm'.
-fno-builtin
不接受不是两个下划线开头的内建函数(built-in function).目前受影响的函数有_exit, abort, abs, alloca, cos, exit, fabs, labs, memcmp, memcpy, sin, sqrt, strcmp, strcpy,和strlen.
`-ansi'选项能够阻止alloca和_exit成为内建函数.

-fhosted
按宿主环境编译;他隐含声明了`-fbuiltin'选项,而且警告不正确的main函数声明.
-ffreestanding
按独立环境编译;他隐含声明了`-fno-builtin'选项,而且对main函数没有特别要求.
(译注:宿主环境(hosted environment)下所有的标准库可用, main函数返回一个int值,典型例子是除了 内核以外几乎所有的程序.对应的独立环境(freestanding environment)不存在标准库,程序入口也不一定是 main,最明显的例子就是操作系统内核.详情参考gcc网站最近的资料)

-fno-strict-prototype
对于没有参数的函数声明,例如`int foo ();',按C风格处理---即不说明参数个数或类型. (仅针对C++).正常情况下,这样的函数foo在C++中意味着参数为空.
-trigraphs
支持ANSI C trigraphs. `-ansi'选项隐含声明了`-trigraphs'.
-traditional
试图支持传统C编译器的某些方面.详见GNU C手册,我们已经把细节清单从这里删除,这样当内容过时后,人们也不会 埋怨我们.
除了一件事:对于C++程序(不是C), `-traditional'选项带来一个附加效应,允许对 this赋值.他和`-fthis-is-variable'选项的效果一样.

-traditional-cpp
试图支持传统C预处理器的某些方面.特别是上面提到有关预处理器的内容,但是不包括 `-traditional'选项的其他效应.
-fdollars-in-identifiers
允许在标识符(identifier)中使用`$'字符(仅针对C++).你可以指定 `-fno-dollars-in-identifiers'选项显明禁止使用`$'符. (GNU C++在某些 目标系统缺省允许`$'符,但不是所有系统.)
-fenum-int-equiv
允许int类型到枚举类型(enumeration)的隐式转换(仅限于C++).正常情况下GNU C++允许从 enum到int的转换,反之则不行.
-fexternal-templates
为模板声明(template declaration)产生较小的代码(仅限于C++),方法是对于每个模板函数 (template function),只在定义他们的地方生成一个副本.想要成功使用这个选项,你必须在所有使用模板的 文件中,标记`#pragma implementation' (定义)或`#pragma interface' (声明).
当程序用`-fexternal-templates'编译时,模板实例(template instantiation) 全部是外部类型.你必须让需要

的实例在实现文件中出现.可以通过typedef实现这一点,他引用所需的每个 实例.相对应的,如果编译时使用缺省选项`-fno-external-templates',所有模板实例明确的设为内置.

-fall-virtual
所有可能的成员函数默认为虚函数.所有的成员函数(除了构造子函数和new或delete 成员操作符)视为所在类的虚函数.
这不表明每次调用成员函数都将通过内部虚函数表.有些情况下,编译器能够判断出可以直接调用某个虚函数;这时就 直接调用.

-fcond-mismatch
允许条件表达式的第二和第三个参数的类型不匹配.这种表达式的值是void.
-fthis-is-variable
允许对this赋值(仅对C++).合并用户自定义的自由存储管理机制到C++后,使可赋值的 `this'显得不合时宜.因此,默认情况下,类成员函数内部对this赋值是无效操作.然而为了 向后兼容,你可以通过`-fthis-is-variable'选项使这种操作有效.
-funsigned-char
把char定义为无符号类型,如同unsigned char.
各种机器都有自己缺省的char类型.既可能是unsigned char也可能是signed char .

理想情况下,当依赖于数据的符号性时,一个可移植程序总是应该使用signed char或unsigned char.但是许多程序已经写成只用简单的char,并且期待这是有符号数(或者无符号数,具体情况取决于 编写程序的目标机器).这个选项,和它的反义选项,使那样的程序工作在对应的默认值上.

char的类型始终应该明确定义为signed char或unsigned char,即使 它表现的和其中之一完全一样.

-fsigned-char
把char定义为有符号类型,如同signed char.
这个选项等同于`-fno-unsigned-char',他是the negative form of `-funsigned-char'的相反选项.同样, `-fno-signed-char'等价于 `-funsigned-char'.

-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
如果没有明确声明`signed'或`unsigned'修饰符,这些选项用来定义有符号位域 (bitfield)或无符号位域.缺省情况下,位域是有符号的,因为他们继承的基本整数类型,如int,是 有符号数.
然而,如果指定了`-traditional'选项,位域永远是无符号数.

-fwritable-strings
把字符串常量存储到可写数据段,而且不做特别对待.这是为了兼容一些老程序,他们假设字符串常量是可写的. `-traditional'选项也有相同效果.
篡改字符串常量是一个非常糟糕的想法; ``常量''就应该是常量.


预处理器选项(Preprocessor Option)
下列选项针对C预处理器,预处理器用在正式编译以前,对C 源文件进行某种处理.
如果指定了`-E'选项, GCC只进行预处理工作.下面的某些选项必须和`-E'选项一起才 有意义,因为他们的输出结果不能用于编译.

-include file
在处理常规输入文件之前,首先处理文件file,其结果是,文件file的内容先得到编译. 命令行

相关文档
最新文档