You are on page 1of 54

GCC

GCC
NAME
gcc,g++-GNUCC++(egcs-1.1.2)
(SYNOPSIS)
gcc[option|filename ]...
g++[option|filename ]...
(WARNING)
GNU C,.
,.,Info, Info
.
,.,
Infoman,GNU CC. GNU
man,.
,Info`gcc'Using and Porting GNU CC (for version
2.0) (GNU CC 2.0) .Texinfo gcc.texinfo.
(DESCRIPTION)
CC++.:
(preprocessing),(compilation),(assembly)(linking).
,,:
gcc
(.i)C,C.
g++
(.i)C++,C++.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (1 of 54)2005-7-9 9:41:47

GCC

:
.c
.C
.cc
.cxx
.m
.i
.ii
.s
.S
.h

C;,,
C++;,,
C++;,,
C++;,,
Objective-C;,,
C;,
C++;,
;
;,
;

(linker).:
.o
.a

(Object file)
(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-intequiv -fexternal-templates -fno-asm -fno-builtin -fhosted -fno-hosted file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (2 of 54)2005-7-9 9:41:47

GCC

ffreestanding -fno-freestanding -fno-strict-prototype -fsignedbitfields -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 -Wenumclash -Werror -Wformat -Wid-clash-len -Wimplicit -Wimplicit-int Wimplicit-function-declaration -Winline -Wlong-long -Wmain -Wmissingprototypes -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 -fpretend-float -g -glevel -gcoff -gxcoff -gxcoff+ -gdwarf
-gdwarf+ -gstabs -gstabs+ -ggdb -p -pg -save-temps -print-filename=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 -iprefix file -iwithprefix dir -M -MD -MM -MMD -

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (3 of 54)2005-7-9 9:41:47

GCC

nostdinc -P -Umacro -undef


(Assembler Option)
-Wa,option
(Linker Option)
-llibrary -nostartfiles -nostdlib -static -shared -symbolic Xlinker option -Wl,option -u symbol
(Directory Option)
-Bprefix -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 -mcypress
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-largeshift -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-argarea -mserialize-volatile -mshort-data-num -msvr3 -msvr4 -mtrap-largefile:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (4 of 54)2005-7-9 9:41:47

GCC

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-fpregs -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 -mnoabicalls -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-fpregs -mdisable-indexing -mtrailing-colon
i960
-mcpu-type -mnumerics -msoft-float -mleaf-procedures -mno-leafprocedures -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-structreturn -fpic -fPIC -freg-struct-return -fshared-data -fshort-enums -

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (5 of 54)2005-7-9 9:41:47

GCC

fshort-double -fvolatile -fvolatile-global -fverbose-asm

(Overall Option)
-x language
language ().
,`-x'. language`c', `objectivec', `c-header', `c++', `cpp-output', `assembler',`assembler-with-cpp'.
-x none
,(`-x').
(,,,),`-x'() gcc
,`-c', `-S',`-E'gcc .,(, `-x cppoutput -E')gcc.
-c
,..
, GCC`.o'`.c', `.i', `.s',,.
-o.
GCC-c().
-S
,.,.
, GCC`.o'`.c', `.i',, .-o
.
GCC.
-E
,..
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (6 of 54)2005-7-9 9:41:47

GCC

GCC.
-o file
file.GCC,,,
C.
,,`-o',
.
`-o',:`a.out', `source.suffix '
`source.o', `source.s',C.
-v
().,,.
-pipe
.,
. GNU.
(LANGUAGE OPTIONS)
C "":
-ansi
ANSIC.
GNU CANSI C,asm, inline typeof,
unixvax. ANSI trigraph
,`$'.
`-ansi',, __asm__, __extension__, __inline__
__typeof__. ANSI C,,
, `-ansi'.,__unix__
__vax__, `-ansi',.
`-ansi'ANSI,`-pedantic' `-ansi'
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (7 of 54)2005-7-9 9:41:47

GCC

.
`-ansi',__STRICT_ANSI__. ,
,,ANSI;
.
-fno-asm
asm, inlinetypeof,. __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), mainint,
.(freestanding environment)
, main,.gcc)
-fno-strict-prototype
,`int foo ();',C---. (
C++).,fooC++.
-trigraphs
ANSI C trigraphs. `-ansi'`-trigraphs'.
-traditional
C.GNU C,,

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (8 of 54)2005-7-9 9:41:47

GCC

, .
:C++(C), `-traditional', this.
`-fthis-is-variable'.
-traditional-cpp
C., `traditional'.
-fdollars-in-identifiers
(identifier)`$'(C++). `-fno-dollars-inidentifiers'`$'. (GNU C++ `$',
.)
-fenum-int-equiv
int(enumeration)(C++).GNU C++
enumint,.
-fexternal-templates
(template declaration)(C++),
(template function),.,
,`#pragma implementation' ()`#pragma
interface' ().
`-fexternal-templates',(template instantiation)
..typedef,
.,`-fno-external-templates',
.
-fall-virtual
.(newdelete
).
.,
; .
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (9 of 54)2005-7-9 9:41:47

GCC

-fcond-mismatch
.void.
-fthis-is-variable
this(C++).C++, `this'
.,,this. ,
`-fthis-is-variable'.
-funsigned-char
char,unsigned char.
char.unsigned charsigned char .
,,signed charunsigned
char.char,(,
).,,.
charsigned charunsigned char,
.
-fsigned-char
char,signed char.
`-fno-unsigned-char',the negative form of `-funsignedchar'., `-fno-signed-char' `-funsigned-char'.
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
`signed'`unsigned', (bitfield)
.,,,int, .
,`-traditional',.
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (10 of 54)2005-7-9 9:41:48

GCC

-fwritable-strings
,.,
. `-traditional'.
; ``''.

(Preprocessor Option)
C,,C .
`-E', GCC.`-E' ,
.
-include file
,file,,file.
`-D'`-U'`-include file', .
`-include'`-imacros'.
-imacros file
,file,.file
, `-imacros file'file,
.`-imacrosfile',`-D' `-U',
.`-include' `-imacros'.
-idirafter dir
dir.(`-I')
,.
-iprefix prefix
prefix`-iwithprefix'.
-iwithprefix dir
.prefixdir, prefix`file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (11 of 54)2005-7-9 9:41:48

GCC

iprefix'.
-nostdinc
.`-I'(,).
`-nostdinc'`-I-',.
-nostdinc++
C++,. (`libg++'
.)
-undef
. ().
-E
C.C,.
-C
.`-E'.
-P
`#line'.`-E'.
-M

[ -MG ]
make,.,
make,(target),
(dependency) `#include.,,
`\'-. ,C.

`-M'`-E'.
`-MG',. `-M'
.
-MM

[ -MG ]
`-M',,`#include file"'.
`#include <file>'.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (12 of 54)2005-7-9 9:41:48

GCC

-MD
`-M',,`.o' `.
d'.---`-MD'`-M'.
Mach`md'`.d',`make' .
-MMD
`-MD',,.
-H
, GCC.
-Aquestion(answer)
,`#if #question(answer)',(Assert)
questionanswer. -A-'.
-Dmacro
macro,`1'.
-Dmacro=defn
macrodefn.`-D' `-U'.
-Umacro
macro. `-U'`-D', `-include'`imacros'.
-dM
().`-E'
.
-dD
,.
-dN
`-dD',.`#define name.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (13 of 54)2005-7-9 9:41:48

GCC

(ASSEMBLER OPTION)
-Wa,option
option.option,.

(LINKER OPTION)
,. ,.
object-file-name
a special recognized suffix, GCC
. (,).GCC,
.
-llibrary
library.
,`liblibrary.a'.
.
,`-L'.
---(archive file).
:,,,
., ,,
.`-l', `-l`lib'`.a'library,
.
-lobjc
-lObjective C.
-nostartfiles
,.
-nostdlib
..

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (14 of 54)2005-7-9 9:41:48

GCC

-static
(dynamic linking),..
-shared
,..
-symbolic
,.(
`-Xlinker -z -Xlinker defs')..
-Xlinker option
option., GNU CC.
,`-Xlinker',,
. ,`-assert definitions',`-Xlinker -assert -Xlinker
definitions',`-Xlinker "-assert definitions"',
,.
-Wl,option
option.option,.
-u symbol
symbol,. `-u',
,.

(DIRECTORY OPTION)
,,,:
-Idir
dir .
-I`-I-'`-I'`#include "file"';
`#include <file>'.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (15 of 54)2005-7-9 9:41:48

GCC

`-I'`-I-',
`#include'. (-I.)
, `-I-'()`#include "file"'
.`-I-'. `-I.',
., .
`-I-',, `-I-'`-nostdinc'.
-Ldir
`-l'dir.
-Bprefix
,,.
: `cpp', `cc1' (C++ `cc1plus'), `as'
`ld'.prefix ,`machine/version/'.
,`-B'().,
`-B',`/usr/lib/gcc/' `/usr/local/lib/
gcc-lib/'.,`PATH'
.
,(run-time)`libgcc.a'`-B'.
,,.,
. , `libgcc.a'.
GCC_EXEC_PREFIX;,
.`-B'GCC_EXEC_PREFIX, `-B',
.

(WARNING OPTION)
,,, .
GNU CC:
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (16 of 54)2005-7-9 9:41:48

GCC

-fsyntax-only
,.
-w
.
-Wno-import
#import.
-pedantic
ANSI C;.
,ANSI C(`-ansi'
).,,GNUC.
. ,(pedant).
(`__') `-pedantic'. Pedantic
__extension__.,
.
-pedantic-errors
`-pedantic',.
-W
:
*
(nonvolatile automatic variable)longjmp.
.
setjmp,longjmp,
.,,,
longjmp.
*
,. (),
:
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (17 of 54)2005-7-9 9:41:48

GCC

foo (a)
{
if (a > 0)
return a;
}

GNU CC(abortlongjmp), .
*
(side effect).,
void.,`x[i,j]',`x[(void)i,
j]'.
*
`>'`<='.
-Wimplicit-int
.
-Wimplicit-function-declaration
.
-Wimplicit
-Wimplicit-int-Wimplicit-function-declaration.
-Wmain
main,.,
, int,,.
-Wreturn-type
,int,.
return,void.
-Wunused
,,
, .
-Wswitch
switch,case,

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (18 of 54)2005-7-9 9:41:48

GCC

. ( default.)case
.
-Wcomment
`/*',.
-Wtrigraphs
trigraph ().
-Wformat
printfscanf,.
-Wchar-subscripts
char.,char.
-Wuninitialized
.
,,
. `-O',.
.volatile,
,1, 2, 4, 8.,
, .
,,.,
.
GNU CC,
. :
{
int x;
switch (y)
{
case 1: x = 1;
break;
case 2: x = 4;
break;
case 3: x = 5;
}
foo (x);
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (19 of 54)2005-7-9 9:41:48

GCC

y1, 23,x,GNU CC. :


{
int save_y;
if (change_y) save_y = y, y = new_y;
...
if (change_y) y = save_y;
}

,save_y.
volatile.
-Wparentheses
,.
-Wtemplate-debugging
C++template,(debugging),.
(C++).
-Wall
`-W'.,

`-W...'`-Wall',, ,
"".
-Wtraditional
CANSI C,.
*
.C,ANSI C.
*
(block),.
*
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (20 of 54)2005-7-9 9:41:48

GCC

switchlong.
-Wshadow
,.
-Wid-clash-len
len,.
,.
-Wpointer-arith
(size)void,. GNU C
void *,1.
-Wcast-qual
,.,const char
* char *,.
-Wcast-align
,(alignment),.
, 24,char *int *
, .
-Wwrite-strings
const char[length],, non-const char
*. ,
const,; `-Wall'
.
-Wconversion
,.
,,(default promotion)
.
-Waggregate-return
,. (,
.)

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (21 of 54)2005-7-9 9:41:48

GCC

-Wstrict-prototypes
,. (
, ,.)
-Wmissing-prototypes
,.
. .
-Wmissing-declarations
,.
. .
-Wredundant-decls
,,.
-Wnested-externs
extern,.
-Wenum-clash
(C++).
-Wlong-long
long long ..`-Wno-long-long'
. `-Wlong-long'`-Wno-long-long' `-pedantic'.
-Woverloaded-virtual
(C++.),(type
signature). ,,
:, ,
,.
-Winline
(inline),inline-finline-functions
,.
-Werror
;.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (22 of 54)2005-7-9 9:41:48

GCC

(DEBUGGING OPTION)
GNU CC,,GCC:
-g
(stabs, COFF, XCOFF,DWARF).. GDB
.
stabs, `-g'GDB;
GDB ,,.
, `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+',
`-gdwarf' ().
C, GNU CC`-g'`-O'.
:;;
;,.
..
GNU CC,.
-ggdb
(),GDB.
-gstabs
stabs(),GDB.BSDDBX.
-gstabs+
stabs(),GNU(GDB)GNU.
.
-gcoff
COFF().System VSystem VSDB
.
-gxcoff

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (23 of 54)2005-7-9 9:41:48

GCC

XCOFF().IBM RS/6000DBX.
-gxcoff+
XCOFF(),GNU(GDB)GNU.
.
-gdwarf
DWARF().System VSDB.
-gdwarf+
DWARF(),GNU(GDB)GNU.
.
-glevel
-ggdblevel
-gstabslevel
-gcofflevel -gxcofflevel
-gdwarflevel
,level.level2.
Level 1,backtrace.
, .
Level 3,.`-g3',
.
-p
,profile,prof.
-pg
,profile,gprof.
-a
,(basic block)profile,,
tcov.,tcov.GNU gprof
.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (24 of 54)2005-7-9 9:41:48

GCC

-ax
,'bb.in'profile,profile'bb.
out' . `bb.in'., profile,
, profile.`-'profile.
, `/path/filename.d:functionname'. `bb.out'
. : `__bb_jumps__'(jump)
`bb.out'. `__bb_trace__' `gzip',`bbtrace.gz'
. `__bb_hidecall__'(trace)call . `__bb_showret__'
.
-dletters
,letters(dump)..
(`foo.c.rtl'`foo.c.jump').
-dM
,.
-dN
.
-dD
,.
-dy
(parse).
-dr
RTL`file.rtl'.
-dx
RTL,.`r'.
-dj
`file.jump'.
-ds
CSE (CSE)`file.cse'.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (25 of 54)2005-7-9 9:41:48

GCC

-dL
`file.loop'.
-dt
CSE(CSE)`file.cse2'.
-df
(flow analysis)`file.flow'.
-dc
(instruction combination)`file.combine'.
-dS
(instruction schedule)`file.sched'.
-dl
`file.lreg'.
-dg
`file.greg'.
-dR
(instruction schedule)`file.sched2'.
-dJ
`file.jump2'.
-dd
(delayed branch scheduling)`file.dbr'.
-dk
-`file.stack'.
-da
.
-dm
,.
-dp
(pattern).

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (26 of 54)2005-7-9 9:41:48

GCC

-fpretend-float
,.,
, GNU CC.
-save-temps
``'';,.,`-c save-temps'`foo.c '` foo.cpp'`foo.s' `foo.o'.
-print-file-name=library
library,---.,
GNU CC,,.
-print-libgcc-file-name
`-print-file-name=libgcc.a'.
-print-prog-name=program
`-print-file-name',program`cpp'.

(OPTIMIZATION OPTION)
:
-O
-O1
.,.
`-O',,.:
,,
, .
`-O',register. `-O'
PCC.
`-O',.
`-O', `-fthread-jumps'`-fdefer-pop' .delay

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (27 of 54)2005-7-9 9:41:48

GCC

slot, `-fdelayed-branch'. (frame pointer)


, `-fomit-frame-pointer'.
.
-O2
.,.
(loop unrolling)(inlining).-O,,
.
-O3
.-O2,-finline-functions.
-O0
.
-O,,.
`-fflag'.; `-ffoo'
`-fno-foo'.--- .
`no-'.
-ffloat-store
.,68000
( 68881)double.
,.IEEE.
`-ffloat-store'.
-fmemoize-lookups
-fsave-memoized
(heuristic)(C++)..
,.
().(1)
; (2)(); (3)
. .,(
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (28 of 54)2005-7-9 9:41:48

GCC

),.
cout << "This " << p << " has " << n << " legs.\n";
., ``''.
, ,. `-fmemoize-lookups'
.
,(), g++
. `-fmemoize-lookups',.`-fsavememoized' ,
, .:
, ,.
-fno-default-inline
,(C++).
-fno-defer-pop
,.,
,.
-fforce-mem
.,
. ,.
.
-fforce-addr
.`-fforce-mem'
..
-fomit-frame-pointer
(frame pointer),.,
;.

.
,Vax,,,
. FRAME_POINTER_REQUIRED.
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (29 of 54)2005-7-9 9:41:48

GCC

-finline-functions
.,.
,static,GCC
.
-fcaller-saves
,,GCC,
..
,.
-fkeep-inline-functions
,static,,
.
-fno-function-cse
;.
,,hack,,
.
-fno-peephole
peephole.
-ffast-math
,GCCANSIIEEE/.,sqrt
.
`-O',IEEEANSI/,
.
. `-O2',`-funroll-loops' `funroll-all-loops'.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (30 of 54)2005-7-9 9:41:48

GCC

`-O'`-fthread-jumps'`-fdelayed-branch' ,
.
``'',.
-fstrength-reduce
(loop strength reduction),.
-fthread-jumps
,,
, .truefalse,
.
-funroll-loops
(loop unrolling)..
-funroll-all-loops
(loop unrolling)...
-fcse-follow-jumps
(common subexpression elimination),
,jump.,CSEelseif,
false, CSEjump.
-fcse-skip-blocks
`-fcse-follow-jumps',CSE,
(block).CSEif,else, `-fcse-skip-blocks'
CSEif.
-frerun-cse-after-loop
,.
-felide-constructors
(C++).,, GNU C++
foo y,:

A foo (); A y = foo ();


file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (31 of 54)2005-7-9 9:41:48

GCC

, GNU C++A y; foo


;,`y'.
ANSI C++(`-fno-elide-constructors').
, `-felide-constructors',
.
-fexpensive-optimizations
.
-fdelayed-branch
,,(delayed branch)
.
-fschedule-insns
,,.
,,.
-fschedule-insns2
`-fschedule-insns',,.
,,.

(TARGET OPTION)
, GNU CC., .
,,GNU CC.`-b' .
,GNU CC.(),
.
-b machine
machine.GNU CC.
machineGNU CC.,

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (32 of 54)2005-7-9 9:41:49

GCC

`configure i386v',80386System V,`-b i386v'


.
`-b',.
-V version
versionGNU CC.GCC.,
version`2.0',GNU CC 2.0.
`-V',GNU CC,.

(MACHINE DEPENDENT OPTION)


,`-m ',---,
6801068020,.,
.
,,.
68000`-m':
-m68000
-mc68000
68000.68000,.
-m68020
-mc68020
68020(68000).68020,
.
-m68881
68881.68020,
-nfp .
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (33 of 54)2005-7-9 9:41:49

GCC

-m68030
68030.68030,.
-m68040
68040.68040,.
-m68020-40
68040,.68020/68881,68030
68040.
-mfpa
SUN FPA.
-msoft-float
. :GNU CC.GCC
C ,.
.
-mshort
int16,short int.
-mnobitfield
(bit-field). `-m68000'`-mnobitfield'.
-mbitfield
. `-m68020'`-mbitfield'.gcc,
.
-mrtd
,,rtd,
. ,.
UNIX.UNIX,
.
,(printf);
.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (34 of 54)2005-7-9 9:41:49

GCC

,,. (,
.)
6801068020rtd,68000.
VAX`-m':
-munix
(aobleq), VAXUNIX(long ranges)
.
-mgnu
GNU,,
-mg
g-format,d-format.
SPARC`-m':
-mfpu
-mhard-float
..

-mno-fpu
-msoft-float
. :SPARCGNU.C
,.,.
-msoft-float;.
-mno-epilogue
-mepilogue
-mepilogue (),.
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (35 of 54)2005-7-9 9:41:49

GCC

(Creturn).
-mno-epilogue,.
-mno-v8
-mv8
-msparclite
SPARC.
(Fujitsu SPARClite), GCCSPARC v7.
-mv8SPARC v8.v7,,
SPARC v8,v7.
-msparcliteSPARClite.SPARClite,
(integer divide step and scan (ffs)). v7.
-mcypress
-msupersparc
,.
-mcypress()Cypress CY7C602, SparcStation/
SparcServer 3xx.SparcStation 1, 2, IPX
..
-msupersparcSuperSparc, SparcStation 10, 1000
2000.SPARC v8.
Convex`-m':
-mc1
C1.C1,.
-mc2

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (36 of 54)2005-7-9 9:41:49

GCC

C2.C2,.
-margcount
(argument count word).Convex
Vax . (,;
.)
-mnoargcount
.gcc,.
AMD Am29000`-m':
-mdw
DW,,..
-mnodw
DW.
-mbw
..
-mnbw
.`-mnodw'.
-msmall
,256 KB,
256K. callconst, consth, calli.
-mlarge
call;.
-m29050
Am29050.
-m29000
Am29000..
-mkernel-registers
gr64-gr95gr96-gr127. ,

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (37 of 54)2005-7-9 9:41:49

GCC

,.
,, `-f'normal, user-mode, names.
-muser-registers
gr96-gr127..
-mstack-check
__msp_check..
Motorola 88K`-m':
-m88000
m88100m88110.
-m88100
m88100,m88110.
-m88110
m88110,m88100.
-midentify-revision
ident,,,,
,
-mno-underscores
,..
-mno-check-zero-division
-mcheck-zero-division
88K,.
( ),,. GCC88K
`-mcheck-zero-division'.
-mocs-debug-info
-mno-ocs-debug-info
()(), 88Open Object
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (38 of 54)2005-7-9 9:41:49

GCC

Compatibility Standard, ``OCS'',. GDB. DG/


UX, SVr4,Delta 88 SVr3.2,88k
.
-mocs-frame-position
-mno-ocs-frame-position
()(OCS). DG/UX, Delta88
SVr3.2 BCS`-mocs-frame-position';88k `mno-ocs-frame-position'.
-moptimize-arg-area
-mno-optimize-arg-area
. `-moptimize-arg-area',
(GDB). `-mno-optimize-arg-area'.GCC
.
-mshort-datanumr0,(data reference),
().num., `mshort-data-512',512. -mshort-data-num
64Knum .

-mserialize-volatile
-mno-serialize-volatile
,.
, GNU CC.
.
m88100,.`-m88100',
GNU CC .
m88110.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (39 of 54)2005-7-9 9:41:49

GCC

. ,.`m88000'`-m88110' , GNU CC.


.,
`-mno-serialize-volatile'.
`-m88100',m88110, `mserialize-volatile'.
-msvr4
-msvr3
(`-msvr4')(`-msvr3')System V(SVr4) .:
*
(`-mversion-03.00').
*
`-msvr4'C`#pragma weak'
*
`-msvr4'GCC(declaration directive),SVr4.
SVr4, `-msvr3'm88K.
-mtrap-large-shift
-mhandle-large-shift
,31(bit-shift);,
(trap)., GCC.
-muse-div-instruction
88K(div),GCC.
GCC .
-mversion-03.00
DG/UXSVr4.-msvr4 ,hybrid-COFF real-ELF
..

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (40 of 54)2005-7-9 9:41:49

GCC

-mwarn-passed-structs
, GCC.C,
, ., GCC.
IBM RS6000:
-mfp-in-toc
-mno-fp-in-toc
(TOC),.,
GCC ;TOC, `-mno-fp-in-toc'TOC,
.
`-m'IBM RT PC:
-min-line-mul
..
-mcall-lib-mul
lmul$$ .
-mfull-fp-blocks
,IBM(scratch space)..
-mminimum-fp-blocks
.,
.
-mfp-arg-in-fpregs
IBM,.,,
varargs.hstdargs.h.
-mfp-arg-in-gregs
..
-mhc-struct-return

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (41 of 54)2005-7-9 9:41:49

GCC

,.MetaWare HighC (hc).


`-fpcc-struct-return'Portable C(pcc).
-mnohc-struct-return
,..IBM,
`-fpcc-struct-return'`-mhc-struct-return'.
`-m'MIPS:
-mcpu=cpu-type
,cpu-type .cpu-type default, GCC
,MIPS
. cpu-typer2000, r3000, r4000, r6000.cpu-type
, GCC, ?? -mips2-mips3,
MIPS ISA (instruction set architecture).
-mips2
MIPS ISA(,). -mcpu=r4000-mcpu=r6000
-mips2.
-mips3
MIPS ISA(64). -mcpu=r4000-mips2. (:mips3)
-mint64
-mlong64
-mlonglong128
.
-mmips-as
MIPS,mips-tfile.
,OSF/1,OSF/rose.-ggdb, -gstabs,
-gstabs+, mips-tfilestabMIPS ECOFF.
-mgas

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (42 of 54)2005-7-9 9:41:49

GCC

GNU.OSF/1,OSF/rose.
-mrnames
-mno-rnames
-mrnamesMIPS,(, a0
$4). GNU-mrnames,MIPSMIPS C. mno-rnames.
-mgpopt
-mno-gpopt
-mgpopt,MIPS
(short global or static data items)
. ,.
-mstats
-mno-stats
(non-inline function), -mstats
(,,).
-mmemcpy
-mno-memcpy
-mmemcpystring(memcpy bcopy),
.
-mmips-tfile
-mno-mips-tfile
MIPSmips-tfile(), -mno-mips-tfile
mips-tfile(postprocess). mips-tfile
., stage2stage3 ,,
.
-msoft-float
. : GNU CC.C
, ,,.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (43 of 54)2005-7-9 9:41:49

GCC

-mhard-float
.,.
-mfp64
FR(on),32 64-bit,32 32-bit
.-mcpu=r4000-mips3.
-mfp32
32 32-bit..

-mabicalls
-mno-abicalls
() .abicalls, .cpload,.cprestore, System V.4
.
-mhalf-pic
-mno-half-pic
-mhalf-pic,,.
.
-G num
numbss,bss.
(gp$28),.
, MIPSnum8,GNU0., -Gnum .
-Gnum.
-nocpp
(`.s'),MIPS.
`-m'Intel 80386: -m486
-mno-486
486.
-msoft-float

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (44 of 54)2005-7-9 9:41:49

GCC

. : GNU CC.C
, ,,.
80387,`-msoft-float',
.
-mno-fp-ret-in-387
FPU.
floatdoubleFPU,FPU.
FPU.
`-mno-fp-ret-in-387'CPU.
`-m'HPPA:
-mpa-risc-1-0
PA 1.0.
-mpa-risc-1-1
PA 1.1.
-mkernel
.add,DP;addil add
.HP-UXbug.
-mshared-libs
HP-UX.,PA.
.
-mno-shared-libs
HP-UX.PA.
-mlong-calls
,256K.
, ``branch out of range errors``.
-mdisable-fpregs
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (45 of 54)2005-7-9 9:41:49

GCC

.,
. ,.
-mdisable-indexing
(indexing address mode).MACHMIG
, .
-mtrailing-colon
(label definition)(ELF).
`-m'Intel 80960:
-mcpu-type
cpu-type ,,. cpu-type
kb;ka, mc, ca, cf, sa,sb.
-mnumerics
-msoft-float
-mnumerics. -msoft-float
.
-mleaf-procedures
-mno-leaf-procedures
()(leaf procedure),balcall .
,bal,,
,,.
-mtail-call
-mno-tail-call
()(),(tailrecursive). ,.-mnotail-call.
-mcomplex-addr
-mno-complex-addr
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (46 of 54)2005-7-9 9:41:49

GCC

()i960,(complex addressing mode).


K,C.CBCC,
-mcomplex-addr.
-mcode-align
-mno-code-align
8(),.C.
-mic-compat
-mic2.0-compat
-mic3.0-compat
iC960 v2.0v3.0.
-masm-compat
-mintel-asm
iC960.
-mstrict-align
-mno-strict-align
().
-mold-align
(structure-alignment)Intelgcc1.3 (gcc 1.37).
,#pragma align 1,.
`-m'DEC Alpha:
-mno-soft-float
-msoft-float
().-msoft-float, `libgcc1.c'
.,, ,
.Alpha,,
.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (47 of 54)2005-7-9 9:41:49

GCC

,Alpha.
-mfp-reg
-mno-fp-regs
(). -mno-fp-regs-msoft-float
.,,$0
$f0. ,,-mno-fp-regs
, .
,,.
System V,:
-G
SVr4, gcc`-G'(). `symbolic'`-shared',gcc.
-Qy
,.ident.
-Qn
.ident().
-YP,dirs
`-l',dirs.dirs .
-Ym,dir
dirM4..

(CODE GENERATION OPTION)


,.
`-f'.; `-ffoo' `-fno-foo'.
---. `no-'.
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (48 of 54)2005-7-9 9:41:49

GCC

-fnonnull-objects
(reference)null (C++).
, GNU C++.,a
null:
obj &a = g (); a.f (2);
,.,
`-fnonnull-objects'.
-fpcc-struct-return
structunion,.,
,;GCCPCC
.
-freg-struct-return
structunion., -fpcc-structreturn.
-fpcc-struct-return ,-freg-struct-return, GNU CC
., GNU CC-fpcc-struct-return.
-fshort-enums
enum., enum
.
-fshort-double
doublefloat.
-fshared-data
const,.
, ,.
-fno-common

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (49 of 54)2005-7-9 9:41:49

GCC

bss,(common block)
. ,(extern ),
. ,,
.
-fno-ident
`#ident'.
-fno-gnu-linker
(C++)GNU(GNU
).GNU,GNU
collect2 (constructor)(destructor). (GNU
CCcollect2 .)collect2,gcc
.
-finhibit-size-directive
.size,,,
. `crtstuff.c';.
-fverbose-asm
.(
).
-fvolatile
(volatile).
-fvolatile-global
.
-fpic
,.(shared library).
-fPIC
,.(dynamic linking),
.
-ffixed-reg

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (50 of 54)2005-7-9 9:41:49

GCC

reg(fixed register);(
,,).
reg.,REGISTER_NAMES
.
,.
-fcall-used-reg
reg,.,
.reg.
,,
.
,.
-fcall-saved-reg
reg.,
.reg.
,,
.
.
,.

PRAGMAS
GNU C++`#pragma':,
.
#pragma interface
file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (51 of 54)2005-7-9 9:41:49

GCC

(C++),.
, (,,)
. pragma.
`#pragma interface', (
`#pragma implementation').,
(reference).
#pragma implementation
#pragma implementation "objects.h"
(C++)(),
pragma. `#pragma interface'.implementation
,,.
`#pragma implementation',;
, `allclass.cc', `#pragma implementation'`#pragma implementation
allclass.h'.implementation,
.
implementation.

(FILE)
file.c
file.h
file.i
file.C
file.cc
file.cxx
file.m
file.s
file.o
a.out
TMPDIR/cc*
LIBDIR/cpp

C
C()
C
C++
C++
C++
Objective-C

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (52 of 54)2005-7-9 9:41:49

GCC

LIBDIR/cc1
C
LIBDIR/cc1plus
C++
LIBDIR/collect
(front end)
LIBDIR/libgcc.a
GCC(subroutine)
/lib/crt[01n].o
(start-up)
LIBDIR/ccrt0
C++
/lib/libc.a
C,intro (3)
/usr/include
#include
LIBDIR/include
#includegcc
LIBDIR/g++-include #includeg++

LIBDIR/usr/local/lib/machine/version.
TMPDIRTMPDIR (,/usr/tmp , /tmp).
(SEE ALSO)
cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1).
info `gcc', `cpp', `as', `ld',`gdb'.
Using and Porting GNU CC (for version 2.0), Richard M. Stallman; The C
Preprocessor, Richard M. Stallman; Debugging with GDB: the GNU Source-Level
Debugger, Richard M. StallmanRoland H. Pesch; Using as: the GNU Assembler,
Dean Elsner, Jay Fenlason & friends; ld: the GNU linker, Steve Chamberlain
Roland Pesch.
BUGS
GCC.
(COPYING)
Copyright 1991, 1992, 1993 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.

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (53 of 54)2005-7-9 9:41:50

GCC

Permission is granted to copy and distribute modified versions of this manual


under the conditions for verbatim copying, provided 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.
(AUTHORS)
GNU CCGUN CC.
Linhan <ningyuanbin@163.com>
2003/05/13

file:///E|/BOOK//Linux/Linhan QQ-3335231 E-mail - ningyuanbin@163.com.htm (54 of 54)2005-7-9 9:41:50

You might also like