Go to the previous, next section.
When you invoke GNU CC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the `-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.
Most of the command line options that you can use with GNU CC 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.
See section Compiling C++ Programs, for a summary of special options for compiling C++ programs.
The gcc
program accepts options and file names as operands. Many
options have multiletter names; therefore multiple single-letter options
may not be grouped: `-dr' is very different from `-d
-r'.
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 `-L' more than once, the directories are searched in the order specified.
Many options have long names starting with `-f' or with `-W'---for example, `-fforce-mem', `-fstrength-reduce', `-Wformat' and so on. Most of these have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. This manual documents only one of these two forms, whichever one is not the default.
Here is a summary of all the options, grouped by type. Explanations are in the following sections.
-c -S -E -o file -pipe -v -x language
-ansi -fallow-single-precision -fcond-mismatch -fno-asm -fno-builtin -fsigned-bitfields -fsigned-char -funsigned-bitfields -funsigned-char -fwritable-strings -traditional -traditional-cpp -trigraphs
-fall-virtual -fdollars-in-identifiers -felide-constructors -fenum-int-equiv -fexternal-templates -fhandle-signatures -fmemoize-lookups -fno-default-inline -fno-strict-prototype -fnonnull-objects -fthis-is-variable -nostdinc++ -traditional +en
-fsyntax-only -pedantic -pedantic-errors -w -W -Wall -Waggregate-return -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment -Wconversion -Wenum-clash -Werror -Wformat -Wid-clash-len -Wimplicit -Wimport -Winline -Wlarger-than-len -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-import -Woverloaded-virtual -Wparentheses -Wpointer-arith -Wredundant-decls -Wreorder -Wreturn-type -Wshadow -Wstrict-prototypes -Wswitch -Wsynth -Wtemplate-debugging -Wtraditional -Wtrigraphs -Wuninitialized -Wunused -Wwrite-strings
-a -dletters -fpretend-float -g -glevel -gcoff -gdwarf -gdwarf+ -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ -p -pg -print-file-name=library -print-libgcc-file-name -print-prog-name=program -save-temps
-fcaller-saves -fcse-follow-jumps -fcse-skip-blocks -fdelayed-branch -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -finline-functions -fkeep-inline-functions -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 -O0 -O1 -O2 -O3
-Aquestion(answer) -C -dD -dM -dN -Dmacro[=defn] -E -H -idirafter dir -include file -imacros file -iprefix file -iwithprefix dir -iwithprefixbefore dir -isystem dir -M -MD -MM -MMD -MG -nostdinc -P -trigraphs -undef -Umacro -Wp,option
-Wa,option
object-file-name -llibrary -nostartfiles -nostdlib -s -static -shared -symbolic -Wl,option -Xlinker option -u symbol
-Bprefix -Idir -I- -Ldir
-b machine -V version
M680x0 Options -m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield -mrtd -mshort -msoft-float VAX Options -mg -mgnu -munix SPARC Options -mapp-regs -mcypress -mepilogue -mflat -mfpu -mhard-float -mhard-quad-float -mno-app-regs -mno-flat -mno-fpu -mno-epilogue -mno-unaligned-doubles -msoft-float -msoft-quad-float -msparclite -msupersparc -munaligned-doubles -mv8 SPARC V9 compilers support the following options in addition to the above: -mmedlow -mmedany -mint32 -mint64 -mlong32 -mlong64 -mno-stack-bias -mstack-bias Convex Options -mc1 -mc2 -mc32 -mc34 -mc38 -margcount -mnoargcount -mlong32 -mlong64 -mvolatile-cache -mvolatile-nocache AMD29K Options -m29000 -m29050 -mbw -mnbw -mdw -mndw -mlarge -mnormal -msmall -mkernel-registers -mno-reuse-arg-regs -mno-stack-check -mno-storem-bug -mreuse-arg-regs -msoft-float -mstack-check -mstorem-bug -muser-registers ARM Options -mapcs -m2 -m3 -m6 -mbsd -mxopen -mno-symrename M88K Options -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 RS/6000 Options and PowerPC -mcpu=cpu type -mpower -mno-power -mpower2 -pno-power2 -mpowerpc -mno-powerpc -mpowerpc-gpopt -mno-powerpc-gpopt -mpowerpc-gfxopt -mno-powerpc-gfxopt -mnew-mnemonics -mno-new-mnemonics -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc RT Options -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 Options -mabicalls -mcpu=cpu type -membedded-data -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64 -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 -mips2 -mips3 -mlong64 -mlong-calls -mmemcpy -mmips-as -mmips-tfile -mno-abicalls -mno-embedded-data -mno-embedded-pic -mno-gpopt -mno-long-calls -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats -mrnames -msoft-float -mstats -G num -nocpp i386 Options -m486 -mieee-fp -mno-486 -mno-fancy-math-387 -mno-fp-ret-in-387 -msoft-float -msvr3-shlib -mno-wide-multiply -mreg-alloc=list HPPA Options -mdisable-fpregs -mdisable-indexing -mjump-in-delay -mgas -mlong-calls -mno-disable-fpregs -mno-disable-indexing -mno-gas -mno-jump-in-delay -mno-long-calls -mno-portable-runtime -mpa-risc-1-0 -mpa-risc-1-1 -mportable-runtime Intel 960 Options -mcpu type -masm-compat -mclean-linkage -mcode-align -mcomplex-addr -mleaf-procedures -mic-compat -mic2.0-compat -mic3.0-compat -mintel-asm -mno-clean-linkage -mno-code-align -mno-complex-addr -mno-leaf-procedures -mno-old-align -mno-strict-align -mno-tail-call -mnumerics -mold-align -msoft-float -mstrict-align -mtail-call DEC Alpha Options -mfp-regs -mno-fp-regs -mno-soft-float -msoft-float Clipper Options -mc300 -mc400 H8/300 Options -mrelax -mh System V Options -Qy -Qn -YP,paths -Ym,dir
-fcall-saved-reg -fcall-used-reg -ffixed-reg -finhibit-size-directive -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 +e0 +e1
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.
For any given input file, the file name suffix determines what kind of compilation is done:
file.c
file.i
file.ii
file.m
file.h
file.cc
file.cxx
file.cpp
file.C
file.s
file.S
other
You can specify the input language explicitly with the `-x' option:
-x language
c objective-c c++ c-header cpp-output c++-cpp-output assembler assembler-with-cpp
-x none
If you only want some of the stages of compilation, you can use
`-x' (or filename suffixes) to tell gcc
where to start, and
one of the options `-c', `-S', or `-E' to say where
gcc
is to stop. Note that some combinations (for example,
`-x cpp-output -E' instruct gcc
to do nothing at all.
-c
By default, the object file name for a source file is made by replacing the suffix `.c', `.i', `.s', etc., with `.o'.
Unrecognized input files, not requiring compilation or assembly, are ignored.
-S
By default, the assembler file name for a source file is made by replacing the suffix `.c', `.i', etc., with `.s'.
Input files that don't require compilation are ignored.
-E
Input files which don't require preprocessing are ignored.
-o file
Since only one output file can be specified, it does not make sense to use `-o' when compiling more than one input file, unless you are producing an executable file as output.
If `-o' is not specified, the default is to put an executable file in `a.out', the object file for `source.suffix' in `source.o', its assembler file in `source.s', and all preprocessed C source on standard output.
-v
-pipe
C++ source files conventionally use one of the suffixes `.C',
`.cc', `cpp', or `.cxx'; preprocessed C++ files use the
suffix `.ii'. GNU CC 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 gcc
).
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 from standard input,
or otherwise without a suffix that flags them as C++ programs.
g++
is a program that calls GNU CC with the default language
set to C++, and automatically specifies linking against the GNU class
library libg++.
(1) On many systems, the script g++
is also
installed with the name c++
.
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. See section Options Controlling C Dialect, for explanations of options for languages related to C. See section Options Controlling C++ Dialect, for explanations of options that are meaningful only for C++ programs.
The following options control the dialect of C (or languages derived from C, such as C++ and Objective C) that the compiler accepts:
-ansi
This turns off certain features of GNU C that are incompatible with ANSI
C, such as the asm
, inline
and typeof
keywords, and
predefined macros such as unix
and vax
that identify the
type of system you are using. It also enables the undesirable and
rarely used ANSI trigraph feature, and disallows `$' as part of
identifiers.
The alternate keywords __asm__
, __extension__
,
__inline__
and __typeof__
continue to work despite
`-ansi'. You would not want to use them in an ANSI C program, of
course, but it is useful to put them in header files that might be included
in compilations done with `-ansi'. Alternate predefined macros
such as __unix__
and __vax__
are also available, with or
without `-ansi'.
The `-ansi' option does not cause non-ANSI programs to be rejected gratuitously. For that, `-pedantic' is required in addition to `-ansi'. See section Options to Request or Suppress Warnings.
The macro __STRICT_ANSI__
is predefined when the `-ansi'
option is used. Some header files may notice this macro and refrain
from declaring certain functions or defining certain macros that the
ANSI standard doesn't call for; this is to avoid interfering with any
programs that might use these names for other things.
The functions alloca
, abort
, exit
, and
_exit
are not builtin functions when `-ansi' is used.
-fno-asm
asm
, inline
or typeof
as a
keyword. These words may then be used as identifiers. You can use the
keywords __asm__
, __inline__
and __typeof__
instead. `-ansi' implies `-fno-asm'.
-fno-builtin
abort
,
abs
, alloca
, cos
, exit
, fabs
,
ffs
, labs
, memcmp
, memcpy
, sin
,
sqrt
, strcmp
, strcpy
, and strlen
.
GCC normally generates special code to handle certain builtin functions
more efficiently; for instance, calls to alloca
may become single
instructions that adjust the stack directly, and calls to 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.
The `-ansi' option prevents alloca
and ffs
from being
builtin functions, since these functions do not have an ANSI standard
meaning.
-trigraphs
-traditional
extern
declarations take effect globally even if they
are written inside of a function definition. This includes implicit
declarations of functions.
typeof
, inline
, signed
, const
and volatile
are not recognized. (You can still use the
alternative keywords such as __typeof__
, __inline__
, and
so on.)
unsigned short
and unsigned char
promote
to unsigned int
.
register
are preserved by
longjmp
. Ordinarily, GNU C follows ANSI C: automatic variables
not declared volatile
may be clobbered.
this
is permitted with
`-traditional'. (The option `-fthis-is-variable' also has
this effect.)
You may wish to use `-fno-builtin' as well as `-traditional' if your program uses names that are normally GNU C builtin functions for other purposes of its own.
You cannot use `-traditional' if you include any header files that rely on ANSI C features. Some vendors are starting to ship systems with ANSI C header files and you cannot use `-traditional' on such systems to compile files that include any system headers.
__STDC__
is not defined when you use
`-traditional', but __GNUC__
is (since the GNU extensions
which __GNUC__
indicates are not affected by
`-traditional'). If you need to write header files that work
differently depending on whether `-traditional' is in use, by
testing both of these predefined macros you can distinguish four
situations: GNU C, traditional GNU C, other ANSI C compilers, and other
old C compilers. See section `Standard Predefined Macros' in The C Preprocessor, for more discussion of these and other
predefined macros.
-traditional-cpp
-fcond-mismatch
-funsigned-char
char
be unsigned, like unsigned char
.
Each kind of machine has a default for what char
should
be. It is either like unsigned char
by default or like
signed char
by default.
Ideally, a portable program should always use signed char
or
unsigned char
when it depends on the signedness of an object.
But many programs have been written to use plain 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 char
is always a distinct type from each of
signed char
or unsigned char
, even though its behavior
is always just like one of those two.
-fsigned-char
char
be signed, like signed char
.
Note that this is equivalent to `-fno-unsigned-char', which is the negative form of `-funsigned-char'. Likewise, the option `-fno-signed-char' is equivalent to `-funsigned-char'.
-fsigned-bitfields
-funsigned-bitfields
-fno-signed-bitfields
-fno-unsigned-bitfields
signed
or unsigned
. By
default, such a bitfield is signed, because this is consistent: the
basic integer types such as int
are signed types.
However, when `-traditional' is used, bitfields are all unsigned no matter what.
-fwritable-strings
Writing into string constants is a very bad idea; "constants" should be constant.
-fallow-single-precision
Traditional K&R C promotes all floating point operations to double precision, regardless of the sizes of the operands. On the architecture for which you are compiling, single precision may be faster than double precision. If you must use `-traditional', but want to use single precision operations when the operands are single precision, use this option. This option has no effect when compiling with ANSI or GNU C conventions (the default).
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 firstClass.C
like this:
g++ -g -felide-constructors -O -c firstClass.C
In this example, only `-felide-constructors' is an option meant only for C++ programs; you can use the other options with any language supported by GNU CC.
Here is a list of options that are only for compiling C++ programs:
-fno-access-control
-fall-virtual
new
or
delete
member operators) are treated as virtual functions of the
class where they appear.
This does not mean that all calls to these member functions will be made through the internal table of virtual functions. Under some circumstances, the compiler can determine that a call to a given virtual function can be made directly; in these cases the calls are direct in any case.
-fconserve-space
main()
has completed, you may have an
object that is being destroyed twice because two definitions were merged.
-fdollars-in-identifiers
-fenum-int-equiv
int
to enumeration types. Normally
GNU C++ allows conversion of enum
to int
, but not the
other way around.
-fexternal-templates
-falt-external-templates
-fno-implicit-templates
-fhandle-signatures
signature
and sigof
keywords for specifying
abstract types. The default (`-fno-handle-signatures') is not to
recognize them. See section Type Abstraction using Signatures.
-fhuge-objects
This flag is not useful when compiling with -fvtable-thunks.
-fno-implement-inlines
-fmemoize-lookups
-fsave-memoized
The first time the compiler must build a call to a member function (or reference to a data member), it must (1) determine whether the class implements member functions of that name; (2) resolve which member function to call (which involves figuring out what sorts of type conversions need to be made); and (3) check the visibility of the member function to the caller. All of this adds up to slower compilation. Normally, the second time a call is made to that member function (or reference to that data member), it must go through the same lengthy process again. This means that code like this:
cout << "This " << p << " has " << n << " legs.\n";
makes six passes through all three steps. By using a software cache, a "hit" significantly reduces this cost. Unfortunately, using the cache introduces another layer of mechanisms which must be implemented, and so incurs its own overhead. `-fmemoize-lookups' enables the software cache.
Because access privileges (visibility) to members and member functions may differ from one function context to the next, G++ may need to flush the cache. With the `-fmemoize-lookups' flag, the cache is flushed after every function that is compiled. The `-fsave-memoized' flag enables the same software cache, but when the compiler determines that the context of the last function compiled would yield the same access privileges of the next function to compile, it preserves the cache. This is most helpful when defining many member functions for the same class: with the exception of member functions which are friends of other classes, each member function has exactly the same access privileges as every other, and the cache need not be flushed.
-fno-strict-prototype
foo
takes no arguments.
This option does not work with operator overloading, which places constraints on the parameter types.
-fnonnull-objects
Normally, GNU C++ makes conservative assumptions about objects reached
through references. For example, the compiler must check that a
is not null in code like the following:
obj &a = g (); a.f (2);
Checking that references of this sort have non-null values requires extra code, however, and it is unnecessary for many programs. You can use `-fnonnull-objects' to omit the checks for null, if your program doesn't require checking.
This checking is currently only done for conversions to virtual base classes.
-fthis-is-variable
this
. The incorporation of user-defined
free store management into C++ has made assignment to `this' an
anachronism. Therefore, by default it is invalid to assign to
this
within a class member function; that is, GNU C++ treats
`this' in a member function of class X
as a non-lvalue of
type `X *'. However, for backwards compatibility, you can make it
valid with `-fthis-is-variable'.
-fvtable-thunks
This option also enables a heuristic for controlling emission of vtables; if a class has any non-inline virtual functions, the vtable will be emitted in the translation unit containing the first one of those.
-nostdinc++
-traditional
In addition, these optimization, warning, and code generation options have meanings only for C++ programs:
-fno-default-inline
-Wenum-clash
-Woverloaded-virtual
-Wtemplate-debugging
+en
cfront
1.x. See section Options for Code Generation Conventions.
Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error.
You can request many specific warnings with options beginning `-W', for example `-Wimplicit' to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning `-Wno-' to turn off warnings; for example, `-Wno-implicit'. This manual lists only one of the two forms, whichever is not the default.
These options control the amount and kinds of warnings produced by GNU CC:
-fsyntax-only
-w
-Wno-import
-pedantic
Valid ANSI standard C programs should compile properly with or without this option (though a rare few will require `-ansi'). However, without this option, certain GNU extensions and traditional C features are supported as well. With this option, they are rejected.
`-pedantic' does not cause warning messages for use of the
alternate keywords whose names begin and end with `__'. Pedantic
warnings are also disabled in the expression that follows
__extension__
. However, only system header files should use
these escape routes; application programs should avoid them.
See section Alternate Keywords.
This option is not intended to be useful; it exists only to satisfy pedants who would otherwise claim that GNU CC fails to support the ANSI standard.
Some users try to use `-pedantic' to check programs for strict ANSI C conformance. They soon find that it does not do quite what they want: it finds some non-ANSI practices, but not all--only those for which ANSI C requires a diagnostic.
A feature to report any failure to conform to ANSI C might be useful in some instances, but would require considerable additional work and would be quite different from `-pedantic'. We recommend, rather, that users take advantage of the extensions of GNU C and disregard the limitations of other compilers. Aside from certain supercomputers and obsolete small machines, there is less and less reason ever to use any other C compiler other than for bootstrapping GNU CC.
-pedantic-errors
-W
longjmp
. These warnings as well are possible only in
optimizing compilation.
The compiler sees only the calls to setjmp
. It cannot know
where longjmp
will be called; in fact, a signal handler could
call it at any point in the code. As a result, you may get a warning
even when there is in fact no problem because longjmp
cannot
in fact be called at the place which would cause a problem.
foo (a) { if (a > 0) return a; }
static
are not the first things in
a declaration. According to the C Standard, this usage is obsolescent.
x.h
:
struct s { int f, g; }; struct t { struct s h; int i; }; struct t x = { 1, 2, 3 };
-Wimplicit
-Wreturn-type
int
. Also warn about any return
statement with no
return-value in a function whose return-type is not void
.
-Wunused
To suppress this warning for a local variable or expression, simply cast it to void. This will also work for file-scope variables, but if you want to mark them used at the point of definition, you can use this macro:
#define USE(var) \ static void *const use_##var = (&use_##var, &var, 0) USE (string);
-Wswitch
switch
statement has an index of enumeral type
and lacks a case
for one or more of the named codes of that
enumeration. (The presence of a default
label prevents this
warning.) case
labels outside the enumeration range also
provoke warnings when this option is used.
-Wcomment
-Wtrigraphs
-Wformat
printf
and scanf
, etc., to make sure that
the arguments supplied have types appropriate to the format string
specified.
-Wchar-subscripts
char
. This is a common cause
of error, as programmers often forget that this type is signed on some
machines.
-Wuninitialized
These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing. If you don't specify `-O', you simply won't get these warnings.
These warnings occur only for variables that are candidates for
register allocation. Therefore, they do not occur for a variable that
is declared volatile
, or whose address is taken, or whose size
is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
structures, unions or arrays, even when they are in registers.
Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed.
These warnings are made optional because GNU CC is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen:
{ int x; switch (y) { case 1: x = 1; break; case 2: x = 4; break; case 3: x = 5; } foo (x); }
If the value of y
is always 1, 2 or 3, then x
is
always initialized, but GNU CC doesn't know this. Here is
another common case:
{ int save_y; if (change_y) save_y = y, y = new_y; ... if (change_y) y = save_y; }
This has no bug because save_y
is used only if it is set.
Some spurious warnings can be avoided if you declare all the functions
you use that never return as noreturn
. See section Declaring Attributes of Functions.
-Wparentheses
-Wenum-clash
-Wtemplate-debugging
-Wreorder (C++ only)
struct A { int i; int j; A(): j (0), i (1) { } };
Here the compiler will warn that the member initializers for `i' and `j' will be rearranged to match the declaration order of the members.
-Wall
The remaining `-W...' options are not implied by `-Wall' because they warn about constructions that we consider reasonable to use, on occasion, in clean programs.
-Wtraditional
switch
statement has an operand of type long
.
-Wshadow
-Wid-clash-len
-Wlarger-than-len
-Wpointer-arith
void
. GNU C assigns these types a size of 1, for
convenience in calculations with void *
pointers and pointers
to functions.
-Wbad-function-cast
int malloc()
is cast to anything *
.
-Wcast-qual
const char *
is cast
to an ordinary char *
.
-Wcast-align
char *
is cast to
an int *
on machines where integers can only be accessed at
two- or four-byte boundaries.
-Wwrite-strings
const char[length]
so that
copying the address of one into a non-const
char *
pointer will get a warning. These warnings will help you find at
compile time code that can try to write into a string constant, but
only if you have been very careful about using const
in
declarations and prototypes. Otherwise, it will just be a nuisance;
this is why we did not make `-Wall' request these warnings.
-Wconversion
Also, warn if a negative integer constant expression is implicitly
converted to an unsigned type. For example, warn about the assignment
x = -1
if x
is unsigned. But do not warn about explicit
casts like (unsigned) -1
.
-Waggregate-return
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
-Wredundant-decls
-Wnested-externs
extern
declaration is encountered within an function.
-Winline
-Woverloaded-virtual
-Wsynth (C++ only)
struct A { operator int (); A& operator = (int); }; main () { A a,b; a = b; }
In this example, g++ will synthesize a default `A& operator = (const A&);', while cfront will use the user-defined `operator ='.
-Werror
GNU CC has various special options that are used for debugging either your program or GCC:
-g
On most systems that use stabs format, `-g' enables use of extra debugging information that only GDB can use; this extra information makes debugging work better in GDB but will probably make other debuggers crash or refuse to read the program. If you want to control for certain whether to generate the extra information, use `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf+', or `-gdwarf' (see below).
Unlike most other C compilers, GNU CC allows you to use `-g' with `-O'. The shortcuts taken by optimized code may occasionally produce surprising results: some variables you declared may not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops.
Nevertheless it proves possible to debug optimized output. This makes it reasonable to use the optimizer for programs that might have bugs.
The following options are useful when GNU CC is generated with the capability for more than one debugging format.
-ggdb
-gstabs
-gstabs+
-gcoff
-gxcoff
-gxcoff+
-gdwarf
-gdwarf+
-glevel
-ggdblevel
-gstabslevel
-gcofflevel
-gxcofflevel
-gdwarflevel
Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, but no information about local variables and no line numbers.
Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use `-g3'.
-p
prof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-pg
gprof
. You must use this option when compiling
the source files you want data about, and you must also use it when
linking.
-a
This data could be analyzed by a program like tcov
. Note,
however, that the format of the data is not what tcov
expects.
Eventually GNU gprof
should be extended to process this data.
-dletters
This is useful when you use `-nostdlib' but you do want to link with `libgcc.a'. You can do
gcc -nostdlib files... `gcc -print-libgcc-file-name`
These options control various sorts of optimizations:
-O
-O1
Without `-O', the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new value to any variable or change the program counter to any other statement in the function and get exactly the results you would expect from the source code.
Without `-O', the compiler only allocates variables declared
register
in registers. The resulting compiled code is a little
worse than produced by PCC without `-O'.
With `-O', the compiler tries to reduce code size and execution time.
When you specify `-O', the compiler turns on `-fthread-jumps' and `-fdefer-pop' on all machines. The compiler turns on `-fdelayed-branch' on machines that have delay slots, and `-fomit-frame-pointer' on machines that can support debugging even without a frame pointer. On some machines the compiler also turns on other flags.
-O2
`-O2' turns on all optional optimizations except for loop unrolling and function inlining. It also turns on frame pointer elimination on machines where doing so does not interfer with debugging.
-O3
-O0
If you use multiple `-O' options, with or without level numbers, the last such option is the one that is effective.
Options of the form `-fflag' specify machine-independent flags. Most flags have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.
-ffloat-store
This option prevents undesirable excess precision on machines such as
the 68000 where the floating registers (of the 68881) keep more
precision than a double
is supposed to have. For most programs,
the excess precision does only good, but a few programs rely on the
precise definition of IEEE floating point. Use `-ffloat-store' for
such programs.
-fno-default-inline
-fno-defer-pop
-fforce-mem
-fforce-addr
-fomit-frame-pointer
On some machines, such as the Vax, this flag has no effect, because
the standard calling sequence automatically handles the frame pointer
and nothing is saved by pretending it doesn't exist. The
machine-description macro FRAME_POINTER_REQUIRED
controls
whether a target machine supports this flag. See section Register Usage.
-fno-inline
inline
keyword. Normally this option
is used to keep the compiler from expanding any functions inline.
Note that if you are not optimizing, no functions can be expanded inline.
-finline-functions
If all calls to a given function are integrated, and the function is
declared static
, then the function is normally not output as
assembler code in its own right.
-fkeep-inline-functions
static
, nevertheless output a separate run-time
callable version of the function.
-fno-function-cse
This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by the optimizations performed when this option is not used.
-ffast-math
sqrt
function are non-negative numbers and that no floating-point values
are NaNs.
This option should never be turned on by any `-O' option since it can result in incorrect output for programs which depend on an exact implementation of IEEE or ANSI rules/specifications for math functions.
The following options control specific optimizations. The `-O2' option turns on all of these optimizations except `-funroll-loops' and `-funroll-all-loops'. On most machines, the `-O' option turns on the `-fthread-jumps' and `-fdelayed-branch' options, but specific machines may handle it differently.
You can use the following flags in the rare cases when "fine-tuning" of optimizations to be performed is desired.
-fstrength-reduce
-fthread-jumps
-fcse-follow-jumps
if
statement with an
else
clause, CSE will follow the jump when the condition
tested is false.
-fcse-skip-blocks
if
statement with no else clause,
`-fcse-skip-blocks' causes CSE to follow the jump around the
body of the if
.
-frerun-cse-after-loop
-fexpensive-optimizations
-fdelayed-branch
-fschedule-insns
-fschedule-insns2
-fcaller-saves
This option is enabled by default on certain machines, usually those which have no call-preserved registers to use instead.
-funroll-loops
-funroll-all-loops
-fno-peephole
These options control the C preprocessor, which is run on each C source file before actual compilation.
If you use the `-E' option, nothing is done except preprocessing. Some of these options make sense only together with `-E' because they cause the preprocessor output to be unsuitable for actual compilation.
-include file
-imacros file
Any `-D' and `-U' options on the command line are always processed before `-imacros file', regardless of the order in which they are written. All the `-include' and `-imacros' options are processed in the order in which they are written.
-idirafter dir
-iprefix prefix
-iwithprefix dir
-iwithprefixbefore dir
-isystem dir
-nostdinc
By using both `-nostdinc' and `-I-', you can limit the include-file search path to only those directories you specify explicitly.
-undef
-E
-C
-P
-M
make
describing the dependencies of each object file. For each source file,
the preprocessor outputs one make
-rule whose target is the object
file name for that source file and whose dependencies are all the
#include
header files it uses. This rule may be a single line or
may be continued with `\'-newline if it is long. The list of rules
is printed on standard output instead of the preprocessed C program.
`-M' implies `-E'.
Another way to specify output of a make
rule is by setting
the environment variable DEPENDENCIES_OUTPUT
(see section Environment Variables Affecting GNU CC).
-MM
-MD
In Mach, you can use the utility md
to merge multiple dependency
files into a single dependency file suitable for using with the `make'
command.
-MMD
-MG
-H
-Aquestion(answer)
-Dmacro
-Dmacro=defn
-Umacro
-dM
-dD
-dN
-trigraphs
-Wp,option
You can pass options to the assembler.
-Wa,option
These options come into play when the compiler links object files into an executable output file. They are meaningless if the compiler is not doing a link step.
object-file-name
-c
-S
-E
-llibrary
It makes a difference where in the command you write this option; the linker searches processes libraries and object files in the order they are specified. Thus, `foo.o -lz bar.o' searches library `z' after file `foo.o' but before `bar.o'. If `bar.o' refers to functions in `z', those functions may not be loaded.
The linker searches a standard list of directories for the library, which is actually a file named `liblibrary.a'. The linker then uses this file as if it had been specified precisely by name.
The directories searched include several standard system directories plus any that you specify with `-L'.
Normally the files found this way are library files--archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an `-l' option and specifying a file name is that `-l' surrounds library with `lib' and `.a' and searches several directories.
-lobjc
-nostartfiles
-nostdlib
One of the standard libraries bypassed by `-nostdlib' is
`libgcc.a', a library of internal subroutines that GNU CC uses to
overcome shortcomings of particular machines, or special needs for some
languages.
(See section Interfacing to GNU CC Output, for more discussion of
`libgcc.a'.)
In most cases, you need `libgcc.a' even when you want to avoid
other standard libraries. In other words, when you specify
`-nostdlib' you should usually specify `-lgcc' as well. This
ensures that you have no unresolved references to internal GNU CC
library subroutines. (For example, `__main', used to ensure C++
constructors will be called; see section collect2
.)
-s
-static
-shared
-symbolic
-Xlinker option
If you want to pass an option that takes an argument, you must use `-Xlinker' twice, once for the option and once for the argument. For example, to pass `-assert definitions', you must write `-Xlinker -assert -Xlinker definitions'. It does not work to write `-Xlinker "-assert definitions"', because this passes the entire string as a single argument, which is not what the linker expects.
-Wl,option
-u symbol
These options specify directories to search for header files, for libraries and for parts of the compiler:
-Idir
-I-
If additional directories are specified with `-I' options after the `-I-', these directories are searched for all `#include' directives. (Ordinarily all `-I' directories are used this way.)
In addition, the `-I-' option inhibits the use of the current directory (where the current input file came from) as the first search directory for `#include "file"'. There is no way to override this effect of `-I-'. With `-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory.
`-I-' does not inhibit the use of the standard system directories for header files. Thus, `-I-' and `-nostdinc' are independent.
-Ldir
-Bprefix
The compiler driver program runs one or more of the subprograms `cpp', `cc1', `as' and `ld'. It tries prefix as a prefix for each program it tries to run, both with and without `machine/version/' (see section Specifying Target Machine and Compiler Version).
For each subprogram to be run, the compiler driver first tries the `-B' prefix, if any. If that name is not found, or if `-B' was not specified, the driver tries two standard prefixes, which are `/usr/lib/gcc/' and `/usr/local/lib/gcc-lib/'. If neither of those results in a file name that is found, the unmodified program name is searched for using the directories specified in your `PATH' environment variable.
`-B' prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into `-L' options for the linker. They also apply to includes files in the preprocessor, because the compiler translates these options into `-isystem' options for the preprocessor. In this case, the compiler appends `include' to the prefix.
The run-time support file `libgcc.a' can also be searched for using the `-B' prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means.
Another way to specify a prefix much like the `-B' prefix is to use
the environment variable GCC_EXEC_PREFIX
. See section Environment Variables Affecting GNU CC.
By default, GNU CC compiles code for the same type of machine that you are using. However, it can also be installed as a cross-compiler, to compile for some other type of machine. In fact, several different configurations of GNU CC, for different target machines, can be installed side by side. Then you specify which one to use with the `-b' option.
In addition, older and newer versions of GNU CC can be installed side by side. One of them (probably the newest) will be the default, but you may sometimes wish to use another.
-b machine
The value to use for machine is the same as was specified as the machine type when configuring GNU CC as a cross-compiler. For example, if a cross-compiler was configured with `configure i386v', meaning to compile for an 80386 running System V, then you would specify `-b i386v' to run that cross compiler.
When you do not specify `-b', it normally means to compile for the same type of machine that you are using.
-V version
The default version, when you do not specify `-V', is controlled by the way GNU CC is installed. Normally, it will be a version that is recommended for general use.
The `-b' and `-V' options actually work by controlling part of the file name used for the executable files and libraries used for compilation. A given version of GNU CC, for a given target machine, is normally kept in the directory `/usr/local/lib/gcc-lib/machine/version'.
Thus, sites can customize the effect of `-b' or `-V' either by changing the names of these directories or adding alternate names (or symbolic links). If in directory `/usr/local/lib/gcc-lib/' the file `80386' is a link to the file `i386v', then `-b 80386' becomes an alias for `-b i386v'.
In one respect, the `-b' or `-V' do not completely change
to a different compiler: the top-level driver program gcc
that you originally invoked continues to run and invoke the other
executables (preprocessor, compiler per se, assembler and linker)
that do the real work. However, since no real work is done in the
driver program, it usually does not matter that the driver program
in use is not the one for the specified target and version.
The only way that the driver program depends on the target machine is in the parsing and handling of special machine-specific options. However, this is controlled by a file which is found, along with the other executables, in the directory for the specified version and target machine. As a result, a single installed driver program adapts to any specified target machine and compiler version.
The driver program executable does control one significant thing, however: the default version and target machine. Therefore, you can install different instances of the driver program, compiled for different targets or versions, under different names.
For example, if the driver for version 2.0 is installed as ogcc
and that for version 2.1 is installed as gcc
, then the command
gcc
will use version 2.1 by default, while ogcc
will use
2.0 by default. However, you can choose either version with either
command with the `-V' option.
Earlier we discussed the standard option `-b' which chooses among different installed compilers for completely different target machines, such as Vax vs. 68000 vs. 80386.
In addition, each of these target machine types can have its own special options, starting with `-m', to choose among various hardware models or configurations--for example, 68010 vs 68020, floating coprocessor or none. A single installed version of the compiler can compile for any model or configuration, according to the options specified.
Some configurations of the compiler also support additional special options, usually for compatibility with other compilers on the same platform.
These options are defined by the macro TARGET_SWITCHES
in the
machine description. The default for the options is also defined by
that macro, which enables you to change the defaults.
These are the `-m' options defined for the 68000 series. The default values for these options depends on which style of 68000 was selected when the compiler was configured; the defaults for the most common choices are given below.
-m68000
-mc68000
-m68020
-mc68020
-m68881
-m68030
-m68040
This option inhibits the use of 68881/68882 instructions that have to be emulated by software on the 68040. If your 68040 does not have code to emulate those instructions, use `-m68040'.
-m68020-40
-mfpa
-msoft-float
-mshort
int
to be 16 bits wide, like short int
.
-mnobitfield
-mbitfield
-mrtd
rtd
instruction, which pops their arguments while returning. This
saves one instruction in the caller since there is no need to pop
the arguments there.
This calling convention is incompatible with the one normally used on Unix, so you cannot use it if you need to call libraries compiled with the Unix compiler.
Also, you must provide function prototypes for all functions that
take variable numbers of arguments (including printf
);
otherwise incorrect code will be generated for calls to those
functions.
In addition, seriously incorrect code will result if you call a function with too many arguments. (Normally, extra arguments are harmlessly ignored.)
The rtd
instruction is supported by the 68010 and 68020
processors, but not by the 68000.
These `-m' options are defined for the Vax:
-munix
aobleq
and so on)
that the Unix assembler for the Vax cannot handle across long
ranges.
-mgnu
-mg
These `-m' switches are supported on the SPARC:
-mno-app-regs
-mapp-regs
To be fully SVR4 ABI compliant at the cost of some performance loss, specify `-mno-app-regs'. You should compile libraries and system software with this option.
-mfpu
-mhard-float
-mno-fpu
-msoft-float
`-msoft-float' changes the calling convention in the output file; therefore, it is only useful if you compile all of a program with this option. In particular, you need to compile `libgcc.a', the library that comes with GNU CC, with `-msoft-float' in order for this to work.
-mhard-quad-float
-msoft-quad-float
As of this writing, there are no sparc implementations that have hardware support for the quad-word floating point instructions. They all invoke a trap handler for one of these instructions, and then the trap handler emulates the effect of the instruction. Because of the trap handler overhead, this is much slower than calling the ABI library routines. Thus the `-msoft-quad-float' option is the default.
-mno-epilogue
-mepilogue
With `-mno-epilogue', the compiler tries to emit exit code inline at every function exit.
-mno-flat
-mflat
With `-mno-flat' (the default), the compiler emits save/restore instructions (except for leaf functions) and is the normal mode of operation.
-mno-unaligned-doubles
-munaligned-doubles
With `-munaligned-doubles', GNU CC assumes that doubles have 8 byte alignment only if they are contained in another type, or if they have an absolute address. Otherwise, it assumes they have 4 byte alignment. Specifying this option avoids some rare compatibility problems with code generated by other compilers. It is not the default because it results in a performance loss, especially for floating point code.
-mv8
-msparclite
By default (unless specifically configured for the Fujitsu SPARClite), GCC generates code for the v7 variant of the SPARC architecture.
`-mv8' will give you SPARC v8 code. The only difference from v7 code is that the compiler emits the integer multiply and integer divide instructions which exist in SPARC v8 but not in SPARC v7.
`-msparclite' will give you SPARClite code. This adds the integer
multiply, integer divide step and scan (ffs
) instructions which
exist in SPARClite but not in SPARC v7.
-mcypress
-msupersparc
With `-mcypress' (the default), the compiler optimizes code for the Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. This is also apropriate for the older SparcStation 1, 2, IPX etc.
With `-msupersparc' the compiler optimizes code for the SuperSparc cpu, as used in the SparcStation 10, 1000 and 2000 series. This flag also enables use of the full SPARC v8 instruction set.
In a future version of GCC, these options will very likely be renamed to `-mcpu=cypress' and `-mcpu=supersparc'.
These `-m' switches are supported in addition to the above on SPARC V9 processors:
-mmedlow
It is very likely that a future version of GCC will rename this option.
-mmedany
It is very likely that a future version of GCC will rename this option.
-mint64
-mlong32
-mlong64
-mint32
-mstack-bias
-mno-stack-bias
These `-m' options are defined for Convex:
-mc1
__convex__c1__
is defined.
-mc2
__convex_c2__
is defined.
-mc32
__convex_c32__
is defined.
-mc34
__convex_c34__
is defined.
-mc38
__convex_c38__
is defined.
-margcount
-mnoargcount
-mvolatile-cache
-mvolatile-nocache
-mlong32
-mlong64
These `-m' options are defined for the AMD Am29000:
-mdw
DW
bit is set, i.e., that byte and
halfword operations are directly supported by the hardware. This is the
default.
-mndw
DW
bit is not set.
-mbw
-mnbw
-msmall
call
instruction to be used instead
of a const
, consth
, calli
sequence.
-mnormal
call
instructions only when
calling functions in the same file and calli
instructions
otherwise. This works if each file occupies less than 256 KB but allows
the entire executable to be larger than 256 KB. This is the default.
-mlarge
calli
instructions. Specify this option if you expect
a single file to compile into more than 256 KB of code.
-m29050
-m29000
-mkernel-registers
gr64-gr95
instead of to
registers gr96-gr127
. This option can be used when compiling
kernel code that wants a set of global registers disjoint from that used
by user-mode code.
Note that when this option is used, register names in `-f' flags must use the normal, user-mode, names.
-muser-registers
gr96-gr127
. This is the
default.
-mstack-check
-mno-stack-check
__msp_check
after each stack
adjustment. This is often used for kernel code.
-mstorem-bug
-mno-storem-bug
-mno-reuse-arg-regs
-mreuse-arg-regs
-msoft-float
These `-m' options are defined for Advanced RISC Machines (ARM) architectures:
-m2
-m3
-m6
-mapcs
-mbsd
-mxopen
-mno-symrename
These `-m' options are defined for Motorola 88k architectures:
-m88000
-m88100
-m88110
-mbig-pic
-midentify-revision
ident
directive in the assembler output recording the
source file name, compiler name and version, timestamp, and compilation
flags used.
-mno-underscores
-mocs-debug-info
-mno-ocs-debug-info
-mocs-frame-position
-mno-ocs-frame-position
-moptimize-arg-area
-mno-optimize-arg-area
-mshort-data-num
r0
,
which allows loading a value using a single instruction (rather than the
usual two). You control which data references are affected by
specifying num with this option. For example, if you specify
`-mshort-data-512', then the data references affected are those
involving displacements of less than 512 bytes.
`-mshort-data-num' is not effective for num greater
than 64k.
-mserialize-volatile
-mno-serialize-volatile
The order of memory references made by the MC88110 processor does not always match the order of the instructions requesting those references. In particular, a load instruction may execute before a preceding store instruction. Such reordering violates sequential consistency of volatile memory references, when there are multiple processors. When consistency must be guaranteed, GNU C generates special instructions, as needed, to force execution in the proper order.
The MC88100 processor does not reorder memory references and so always provides sequential consistency. However, by default, GNU C generates the special instructions to guarantee consistency even when you use `-m88100', so that the code may be run on an MC88110 processor. If you intend to run your code only on the MC88100 processor, you may use `-mno-serialize-volatile'.
The extra code generated to guarantee consistency may affect the performance of your application. If you know that you can safely forgo this guarantee, you may use `-mno-serialize-volatile'.
-msvr4
-msvr3
`-msvr4' is the default for the m88k-motorola-sysv4 and m88k-dg-dgux m88k configurations. `-msvr3' is the default for all other m88k configurations.
-mversion-03.00
-mno-check-zero-division
-mcheck-zero-division
Some models of the MC88100 processor fail to trap upon integer division by zero under certain conditions. By default, when compiling code that might be run on such a processor, GNU C generates code that explicitly checks for zero-valued divisors and traps with exception number 503 when one is detected. Use of mno-check-zero-division suppresses such checking for code generated to run on an MC88100 processor.
GNU C assumes that the MC88110 processor correctly detects all instances of integer division by zero. When `-m88110' is specified, both `-mcheck-zero-division' and `-mno-check-zero-division' are ignored, and no explicit checks for zero-valued divisors are generated.
-muse-div-instruction
On the MC88100 processor the signed integer division instruction div) traps to the operating system on a negative operand. The operating system transparently completes the operation, but at a large cost in execution time. By default, when compiling code that might be run on an MC88100 processor, GNU C emulates signed integer division using the unsigned integer division instruction divu), thereby avoiding the large penalty of a trap to the operating system. Such emulation has its own, smaller, execution cost in both time and space. To the extent that your code's important signed integer division operations are performed on two nonnegative operands, it may be desirable to use the div instruction directly.
On the MC88110 processor the div instruction (also known as the divs instruction) processes negative operands without trapping to the operating system. When `-m88110' is specified, `-muse-div-instruction' is ignored, and the div instruction is used for signed integer division.
Note that the result of dividing INT_MIN by -1 is undefined. In particular, the behavior of such a division with and without `-muse-div-instruction' may differ.
-mtrap-large-shift
-mhandle-large-shift
-mwarn-passed-structs
These `-m' options are defined for the IBM RS/6000 and PowerPC:
-mpower
-mno-power
-mpower2
-mno-power2
-mpowerpc
-mno-powerpc
-mpowerpc-gpopt
-mno-powerpc-gpopt
-mpowerpc-gfxopt
-mno-powerpc-gfxopt
Neither architecture is a subset of the other. However there is a large common subset of instructions supported by both. An MQ register is included in processors supporting the POWER architecture.
You use these options to specify which instructions are available on the processor you are using. The default value of these options is determined when configuring GNU CC. Specifying the `-mcpu=cpu_type' overrides the specification of these options. We recommend you use that option rather than these.
The `-mpower' option allows GNU CC to generate instructions that are found only in the POWER architecture and to use the MQ register. Specifying `-mpower2' implies `-power' and also allows GNU CC to generate instructions that are present in the POWER2 architecture but not the original POWER architecture.
The `-mpowerpc' option allows GNU CC to generate instructions that are found only in the 32-bit subset of the PowerPC architecture. Specifying `-mpowerpc-gpopt' implies `-mpowerpc' and also allows GNU CC to use the optional PowerPC architecture instructions in the General Purpose group, including floating-point square root. Specifying `-mpowerpc-gfxopt' implies `-mpowerpc' and also allows GNU CC to use the optional PowerPC architecture instructions in the Graphics group, including floating-point select.
If you specify both `-mno-power' and `-mno-powerpc', GNU CC will use only the instructions in the common subset of both architectures plus some special AIX common-mode calls, and will not use the MQ register. Specifying both `-mpower' and `-mpowerpc' permits GNU CC to use any instruction from either architecture and to allow use of the MQ register; specify this for the Motorola MPC601.
-mnew-mnemonics
-mold-mnemonics
PowerPC assemblers support both the old and new mnemonics, as will later POWER assemblers. Current POWER assemblers only support the old mnemonics. Specify `-mnew-mnemonics' if you have an assembler that supports them, otherwise specify `-mold-mnemonics'.
The default value of these options depends on how GNU CC was configured. Specifing `-mcpu=cpu_type' sometimes overrides the value of these option. Unless you are building a cross-compiler, you should normally not specify either `-mnew-mnemonics' or `-mold-mnemonics', but should instead accept the default.
-mcpu=cpu_type
Specifying `-mcpu=rios1', `-mcpu=rios2', `-mcpu=rsc', or `-mcpu=power' enables the `-mpower' option and disables the `-mpowerpc' option; `-mcpu=601' enables both the `-mpower' and `-mpowerpc' options; `-mcpu=603', `-mcpu=604', and `-mcpu=powerpc' enable the `-mpowerpc' option and disable the `-mpower' option; `-mcpu=common' disables both the `-mpower' and `-mpowerpc' options.
To generate code that will operate on all members of the RS/6000 and PowerPC families, specify `-mcpu=common'. In that case, GNU CC will use only the instructions in the common subset of both architectures plus some special AIX common-mode calls, and will not use the MQ register. GNU CC assumes a generic processor model for scheduling purposes.
Specifying `-mcpu=rios1', `-mcpu=rios2', `-mcpu=rsc', or `-mcpu=power' also disables the `new-mnemonics' option. Specifying `-mcpu=601', `-mcpu=603', `-mcpu=604', or `-mcpu=powerpc' also enables the `new-mnemonics' option.
-mfull-toc
-mno-fp-in-toc
-mno-sum-in-toc
-mminimal-toc
If you receive a linker error message that saying you have overflowed the available TOC space, you can reduce the amount of TOC space used with the `-mno-fp-in-toc' and `-mno-sum-in-toc' options. `-mno-fp-in-toc' prevents GNU CC from putting floating-point constants in the TOC and `-mno-sum-in-toc' forces GNU CC to generate code to calculate the sum of an address and a constant at run-time instead of putting that sum into the TOC. You may specify one or both of these options. Each causes GNU CC to produce very slightly slower and larger code at the expense of conserving TOC space.
If you still run out of space in the TOC even when you specify both of these options, specify `-mminimal-toc' instead. This option causes GNU CC to make only one TOC entry for every file. When you specify this option, GNU CC will produce code that is slower and larger but which uses extremely little TOC space. You may wish to use this option only on files that contain less frequently executed code.
These `-m' options are defined for the IBM RT PC:
-min-line-mul
-mcall-lib-mul
lmul$$
for integer multiples.
-mfull-fp-blocks
-mminimum-fp-blocks
-mfp-arg-in-fpregs
varargs.h
and stdargs.h
will not work with
floating point operands if this option is specified.
-mfp-arg-in-gregs
-mhc-struct-return
-mnohc-struct-return
These `-m' options are defined for the MIPS family of computers:
-mcpu=cpu type
-mips1
-mips2
-mips3
-mfp32
-mfp64
-mgp32
-mgp64
-mint64
-mlong64
-mmips-as
-mgas
-mrnames
-mno-rnames
-mgpopt
-mno-gpopt
-mstats
-mno-stats
-mmemcpy
-mno-memcpy
-mmips-tfile
-mno-mips-tfile
-msoft-float
-mhard-float
-mabicalls
-mno-abicalls
-mlong-calls
-mno-long-calls
-mhalf-pic
-mno-half-pic
-membedded-pic
-mno-embedded-pic
-membedded-data
-mno-embedded-data
-G num
-nocpp
These options are defined by the macro
TARGET_SWITCHES
in the machine description. The default for the
options is also defined by that macro, which enables you to change the
defaults.
These `-m' options are defined for the i386 family of computers:
-m486
-mno-486
-mieee-fp
-m-no-ieee-fp
-msoft-float
On machines where a function returns floating point results in the 80387 register stack, some floating point opcodes may be emitted even if `-msoft-float' is used.
-mno-fp-ret-in-387
The usual calling convention has functions return values of types
float
and double
in an FPU register, even if there
is no FPU. The idea is that the operating system should emulate
an FPU.
The option `-mno-fp-ret-in-387' causes such values to be returned in ordinary CPU registers instead.
-mno-fancy-math-387
sin
, cos
and
sqrt
instructions for the 387. Specify this option to avoid
generating those instructions. This option is the default on FreeBSD.
As of revision 2.6.1, these instructions are not generated unless you
also use the `-ffast-math' switch.
-msvr3-shlib
-mno-svr3-shlib
bss
or
data
. `-msvr3-shlib' places these locals into bss
.
These options are meaningful only on System V Release 3.
-mno-wide-multiply
-mwide-multiply
mul
and imul
that produce
64 bit results in eax:edx
from 32 bit operands to do long
long
multiplies and 32-bit division by constants.
-mreg-alloc=regs
a
allocate EAX; b
allocate EBX;
c
allocate ECX; d
allocate EDX; S
allocate ESI;
D
allocate EDI; B
allocate EBP.
These `-m' options are defined for the HPPA family of computers:
-mpa-risc-1-0
-mpa-risc-1-1
-mjump-in-delay
-mlong-calls
-mdisable-fpregs
-mdisable-indexing
-mportable-runtime
-mgas
These `-m' options are defined for the Intel 960 implementations:
-mcpu type
-mnumerics
-msoft-float
-mleaf-procedures
-mno-leaf-procedures
bal
instruction as well as call
. This will result in more
efficient code for explicit calls when the bal
instruction can be
substituted by the assembler or linker, but less efficient code in other
cases, such as calls via function pointers, or using a linker that doesn't
support this optimization.
-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
These `-m' options are defined for the DEC Alpha implementations:
-mno-soft-float
-msoft-float
-msoft-float
is specified,
functions in `libgcc1.c' will be used to perform floating-point
operations. Unless they are replaced by routines that emulate the
floating-point operations, or compiled in such a way as to call such
emulations routines, these routines will issue floating-point
operations. If you are compiling for an Alpha without floating-point
operations, you must ensure that the library is built so as not to call
them.
Note that Alpha implementations without floating-point operations are required to have floating-point registers.
-mfp-reg
-mno-fp-regs
-mno-fp-regs
implies -msoft-float
. If the floating-point
register set is not used, floating point operands are passed in integer
registers as if they were integers and floating-point results are passed
in $0 instead of $f0. This is a non-standard calling sequence, so any
function with a floating-point argument or return value called by code
compiled with -mno-fp-regs
must also be compiled with that
option.
A typical use of this option is building a kernel that does not use, and hence need not save and restore, any floating-point registers.
These `-m' options are defined for the Clipper implementations:
-mc300
-mc400
These `-m' options are defined for the H8/300 implementations:
-mrelax
ld
and the H8/300' in Using ld, for a fuller description.
-mh
These additional options are available on System V Release 4 for compatibility with other compilers on those systems:
-Qy
.ident
assembler directive in the output.
-Qn
.ident
directives to the output file (this is
the default).
-YP,dirs
-Ym,dir
These machine-independent options control the interface conventions used in code generation.
Most of them have both positive and negative forms; the negative form of `-ffoo' would be `-fno-foo'. In the table below, only one of the forms is listed--the one which is not the default. You can figure out the other form by either removing `no-' or adding it.
-fpcc-struct-return
struct
and union
values in memory like
longer ones, rather than in registers. This convention is less
efficient, but it has the advantage of allowing intercallability between
GNU CC-compiled files and files compiled with other compilers.
The precise convention for returning structures in memory depends on the target configuration macros.
Short structures and unions are those whose size and alignment match that of some integer type.
-freg-struct-return
struct
and union
values are
returned in registers when possible. This is more efficient for small
structures than `-fpcc-struct-return'.
If you specify neither `-fpcc-struct-return' nor its contrary `-freg-struct-return', GNU CC defaults to whichever convention is standard for the target. If there is no standard convention, GNU CC defaults to `-fpcc-struct-return', except on targets where GNU CC is the principal compiler. In those cases, we can choose the standard, and we chose the more efficient register return alternative.
-fshort-enums
enum
type only as many bytes as it needs for the
declared range of possible values. Specifically, the enum
type
will be equivalent to the smallest integer type which has enough room.
-fshort-double
double
as for float
.
-fshared-data
const
variables of this
compilation be shared data rather than private data. The distinction
makes sense only on certain operating systems, where shared data is
shared between processes running the same program, while private data
exists in one copy per process.
-fno-common
extern
) in
two different compilations, you will get an error when you link them.
The only reason this might be useful is if you wish to verify that the
program will work on other systems which always work this way.
-fno-ident
-fno-gnu-linker
collect2
program to make sure the system linker includes
constructors and destructors. (collect2
is included in the GNU CC
distribution.) For systems which must use collect2
, the
compiler driver gcc
is configured to do this automatically.
-finhibit-size-directive
.size
assembler directive, or anything else that
would cause trouble if the function is split in the middle, and the
two halves are placed at locations far apart in memory. This option is
used when compiling `crtstuff.c'; you should not need to use it
for anything else.
-fverbose-asm
-fvolatile
-fvolatile-global
-fpic
Position-independent code requires special support, and therefore works only on certain machines. For the 386, GNU CC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.
The GNU assembler does not fully support PIC. Currently, you must use some other assembler in order for PIC to work. We would welcome volunteers to upgrade GAS to handle this; the first part of the job is to figure out what the assembler must do differently.
-fPIC
Position-independent code requires special support, and therefore works only on certain machines.
-ffixed-reg
reg must be the name of a register. The register names accepted
are machine-specific and are defined in the REGISTER_NAMES
macro in the machine description macro file.
This flag does not have a negative form, because it specifies a three-way choice.
-fcall-used-reg
Use of this flag for a register that has a fixed pervasive role in the machine's execution model, such as the stack pointer or frame pointer, will produce disastrous results.
This flag does not have a negative form, because it specifies a three-way choice.
-fcall-saved-reg
Use of this flag for a register that has a fixed pervasive role in the machine's execution model, such as the stack pointer or frame pointer, will produce disastrous results.
A different sort of disaster will result from the use of this flag for a register in which function values may be returned.
This flag does not have a negative form, because it specifies a three-way choice.
+e0
+e1
These options are provided for compatibility with cfront
1.x
usage; the recommended alternative GNU C++ usage is in flux. See section Declarations and Definitions in One Header.
With `+e0', virtual function definitions in classes are declared
extern
; the declaration is used only as an interface
specification, not to generate code for the virtual functions (in this
compilation).
With `+e1', G++ actually generates the code implementing virtual functions defined in the code, and makes them publicly visible.
This section describes several environment variables that affect how GNU CC operates. They work by specifying directories or prefixes to use when searching for various kinds of files.
Note that you can also specify places to search using options such as `-B', `-I' and `-L' (see section Options for Directory Search). These take precedence over places specified using environment variables, which in turn take precedence over those specified by the configuration of GNU CC. See section Controlling the Compilation Driver, `gcc'.
TMPDIR
TMPDIR
is set, it specifies the directory to use for temporary
files. GNU CC uses temporary files to hold the output of one stage of
compilation which is to be used as input to the next stage: for example,
the output of the preprocessor, which is the input to the compiler
proper.
GCC_EXEC_PREFIX
GCC_EXEC_PREFIX
is set, it specifies a prefix to use in the
names of the subprograms executed by the compiler. No slash is added
when this prefix is combined with the name of a subprogram, but you can
specify a prefix that ends with a slash if you wish.
If GNU CC cannot find the subprogram using the specified prefix, it tries looking in the usual places for the subprogram.
The default value of GCC_EXEC_PREFIX
is
`prefix/lib/gcc-lib/machine/version/' where
prefix is the value of prefix
when you ran the
`configure' script and machine and version are the
configuration name and version number of GNU CC, respectively.
Other prefixes specified with `-B' take precedence over this prefix.
This prefix is also used for finding files such as `crt0.o' that are used for linking.
In addition, the prefix is used in an unusual way in finding the
directories to search for header files. For each of the standard
directories whose name normally begins with `/usr/local/lib/gcc-lib'
(more precisely, with the value of GCC_INCLUDE_DIR
), GNU CC tries
replacing that beginning with the specified prefix to produce an
alternate directory name. Thus, with `-Bfoo/', GNU CC will search
`foo/bar' where it would normally search `/usr/local/lib/bar'.
These alternate directories are searched first; the standard directories
come next.
COMPILER_PATH
COMPILER_PATH
is a colon-separated list of
directories, much like PATH
. GNU CC tries the directories thus
specified when searching for subprograms, if it can't find the
subprograms using GCC_EXEC_PREFIX
.
LIBRARY_PATH
LIBRARY_PATH
is a colon-separated list of
directories, much like PATH
. GNU CC tries the directories thus
specified when searching for special linker files, if it can't find them
using GCC_EXEC_PREFIX
. Linking using GNU CC also uses these
directories when searching for ordinary libraries for the `-l'
option (but directories specified with `-L' come first).
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
PATH
. When GNU CC searches for header files, it tries the
directories listed in the variable for the language you are using, after
the directories specified with `-I' but before the standard header
file directories.
DEPENDENCIES_OUTPUT
The value of DEPENDENCIES_OUTPUT
can be just a file name, in
which case the Make rules are written to that file, guessing the target
name from the source file name. Or the value can have the form
`file target', in which case the rules are written to
file file using target as the target name.
The program protoize
is an optional part of GNU C. You can use
it to add prototypes to a program, thus converting the program to ANSI
C in one respect. The companion program unprotoize
does the
reverse: it removes argument types from any prototypes that are found.
When you run these programs, you must specify a set of source files as command line arguments. The conversion programs start out by compiling these files to see what functions they define. The information gathered about a file foo is saved in a file named `foo.X'.
After scanning comes actual conversion. The specified files are all eligible to be converted; any files they include (whether sources or just headers) are eligible as well.
But not all the eligible files are converted. By default,
protoize
and unprotoize
convert only source and header
files in the current directory. You can specify additional directories
whose files should be converted with the `-d directory'
option. You can also specify particular files to exclude with the
`-x file' option. A file is converted if it is eligible, its
directory name matches one of the specified directory names, and its
name within the directory has not been excluded.
Basic conversion with protoize
consists of rewriting most
function definitions and function declarations to specify the types of
the arguments. The only ones not rewritten are those for varargs
functions.
protoize
optionally inserts prototype declarations at the
beginning of the source file, to make them available for any calls that
precede the function's definition. Or it can insert prototype
declarations with block scope in the blocks where undeclared functions
are called.
Basic conversion with unprotoize
consists of rewriting most
function declarations to remove any argument types, and rewriting
function definitions to the old-style pre-ANSI form.
Both conversion programs print a warning for any function declaration or definition that they can't convert. You can suppress these warnings with `-q'.
The output from protoize
or unprotoize
replaces the
original source file. The original file is renamed to a name ending
with `.save'. If the `.save' file already exists, then
the source file is simply discarded.
protoize
and unprotoize
both depend on GNU CC itself to
scan the program and collect information about the functions it uses.
So neither of these programs will work until GNU CC is installed.
Here is a table of the options you can use with protoize
and
unprotoize
. Each option works with both programs unless
otherwise stated.
-B directory
protoize
.
-c compilation-options
gcc
to
produce the `.X' files. The special option `-aux-info' is
always passed in addition, to tell gcc
to write a `.X' file.
Note that the compilation options must be given as a single argument to
protoize
or unprotoize
. If you want to specify several
gcc
options, you must quote the entire set of compilation options
to make them a single word in the shell.
There are certain gcc
arguments that you cannot use, because they
would produce the wrong kind of output. These include `-g',
`-O', `-c', `-S', and `-o' If you include these in
the compilation-options, they are ignored.
-C
protoize
.
-g
protoize
.
-i string
protoize
.
unprotoize
converts prototyped function definitions to old-style
function definitions, where the arguments are declared between the
argument list and the initial `{'. By default, unprotoize
uses five spaces as the indentation. If you want to indent with just
one space instead, use `-i " "'.
-k
-l
protoize
with `-l' inserts
a prototype declaration for each function in each block which calls the
function without any declaration. This option applies only to
protoize
.
-n
-N
-p program
-q
-v
gcc
.
If you need special compiler options to compile one of your program's
source files, then you should generate that file's `.X' file
specially, by running gcc
on that source file with the
appropriate options and the option `-aux-info'. Then run
protoize
on the entire set of files. protoize
will use
the existing `.X' file because it is newer than the source file.
For example:
gcc -Dfoo=bar file1.c -aux-info protoize *.c
You need to include the special files along with the rest in the
protoize
command, even though their `.X' files already
exist, because otherwise they won't get converted.
See section Caveats of using protoize
, for more information on how to use
protoize
successfully.
Go to the previous, next section.