CC
Section: User Commands (1)
Updated: June 15, 1989
Index
Return to Main Contents
NAME
cc - GNU C Compiler
SYNOPSIS
cc
[ options ] ... file ...
DESCRIPTION
cc
is the
GNU C compiler, which
translates programs written in the C
programming language into executable load modules, or into relocatable
binary programs for subsequent loading with the
ld(1)
linker.
The
GNU C compiler
uses a command syntax much like the UNIX C compiler. The
cc
program accepts options and file names as operands. Multiple
single-letter options may
not
be grouped: `-dr'
is very different from `-d -r'.
When you invoke
GNU CC, it normally does preprocessing, compilation,
assembly and linking. File names which end in `.c'
are taken as C
source to be preprocessed and compiled; compiler output files plus any
input files with names ending in `.s'
are assembled; then the
resulting object files, plus any other input files, are linked together to
produce an executable.
Command 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 command options are passed on to one stage.
Some options control the preprocessor and others the compiler itself.
GNU CC on the NeXT Computer has been substantially
modified and extended by NeXT Computer, Inc. to support the use of Objective-C and
Mach.
For documentation, see
the NeXT Developer's Library
(accessible through the NeXT Developer target of the Digital Librarian).
OPTIONS
Command options allow you to affect various stages of the compilation process
For example, the -c option says not to run the linker. Then the output
consists of object files produced by the assembler.
Some command options control the overall compilation process, while
some options are passed to one stage of the compilation process.
For example, some options control just the preprocessor (cpp) and others
just the compiler proper (cc1). Other options control the assembler and
linker.
Here are the options to control the overall compilation process. This list
includes the options that say whether to link, whether to assemble, and so
on.
- -o file
-
Place output in file file. This applies to whatever type of
output is being produced; it could be an executable file, an object file,
an assembler file, or preprocessed C code.
-
If -o isn't specified, the default is to put an executable file in
a.out, an object file created from source.c in source.o, an assembler file
in source.s, and preprocessed C on standard output.
- -c
-
Compile or assemble the source files, but don't link. Produce object
files with names made by replacing ".c" or ".s" with ".o" at the end of the
input file names. Do nothing at all to object files specified as input.
- -S
-
Compile into assembler code but don't assemble. The assembler output
file name is made by replacing ".c" with ".s" at the end of the input file
name. Do nothing at all to assembler source files or object files
specified as input.
- -E
-
Run only the C preprocessor. Preprocess the C source files and direct
the results to the standard output.
- -v
-
Compile verbosely. The compiler driver program prints the commands it
executes as it runs the preprocessor, compiler proper, assembler, and
linker. Some of these are directed to print their own version numbers.
- -vt
-
Show timing information for each of the passes run by the cc
command.
- -arch arch_type
-
Compile for the specified architecture.
For example, specifying
-arch i386 -arch m68k
compiles for both the i386 and m68k architectures,
and
-arch i386
compiles for only the i386 architecture.
(i386 is the processor family of the i486 processor.)
The full list of values for
arch_type
is in
arch(3);
for now, you should use only m68k and i386.
The operations affected by
-arch
are preprocessing, precompiling, compiling, assembling, and linking.
Specifying multiple architectures results
in the production of ``fat'' output files.
It is an error to use
-E,
-S,
-M,
or
-MM
with multiple architectures
as the output form is textual in these cases.
- -Bprefix
-
Compiler driver program tries prefix as a prefix for each
program it tries to run. These programs are cpp, cc1, as,
and ld.
-
For each subprogram to be run, the compiler driver first tries the -B
prefix, if any. If that name isn't found, or if -B wasn't specified, the
driver tries two standard prefixes, /usr/lib/gcc- and
/usr/local/lib/gcc-.
If neither of those results in a file name that's found, the unmodified
program name is searched for using the directories specified in your PATH
environment variable.
-
The run-time support file gnulib is also searched for using the -B
prefix, if needed. If it isn't found there, the two standard prefixes
above are tried. The file is left out of the link if it isn't found by
those means.
These C compiler 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 C preprocessing. Some of these options make sense only
together with -E because they request preprocessor output that isn't
suitable for actual compilation.
- -C
-
Tell the preprocessor not to discard comments. Used with the -E
option.
- -Idir
-
Search the directory dir for header files.
- -I-
-
Any directories specified with -I options before the -I- option are
searched only for the case of #include "file"; they aren't searched for
#include <file>.
-
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
as the first search directory for #include "file". Therefore, the current
directory is searched only if it's requested explicitly with a -I. option.
Specifying both -I- and -I. allows you to control precisely which
directories are searched before the current one and which are searched
after.
- -nostdinc
-
Don't search the standard system directories for header files.
Only the directories you have specified with -I options (and the current
directory, if appropriate) are searched.
-
Between -nostdinc and -I-, you can eliminate all directories from the
search path except those you specify.
- -M
-
Tell the preprocessor to produce a rule suitable for make describing
the dependencies of each source file. For each source file, the
preprocessor produces one make rule whose target is the object file name
for that source file and whose dependencies are all the files #included in
it. This rule may be a single line or may be continued with
backslash-newline if it's long.
-
-M implies -E (that is, run only the C preprocessor).
- -MD file
-
This is similar to -M, but it turns on the Mach-style
make-depend switch, which writes dependency information to file.
- -MM
-
Like -M but the output mentions only the user-header files included
with #include "file". System header files included with #include <file>
are omitted.
-
-MM implies -E (that is, run only the C preprocessor).
- -MMD file
-
This is similar to -MM, but it uses the Mach-style make-depend switch,
which writes dependency information to file.
- -Dmacro
-
Define macro macro with the empty string as its definition.
- -Dmacro=definition
-
Predefine macro as a macro, with definition definition.
- -Umacro
-
Undefine macro macro.
- -T
-
Support ANSI C trigraphs (the -ansi option also has this effect).
Trigraphs are three-character sequences, all starting with ??, that are
defined by ANSI C to stand for single characters (these sequences allow
users to use the full range of C characters, even if their keyboards don't
implement the full C character set). For example, ??/ stands for \ so ??/n
is a character constant for newline.
The following options control the details of C compilation (that is, just
the portion of the compilation process related to cc1, the compiler
proper).
- -ansi
-
Support all ANSI standard C programs. This turns off certain
features of GNU C that are incompatible with ANSI C, and enables the
infrequently used ANSI trigraph feature.
-
The -ansi option doesn't cause non-ANSI programs to be rejected
gratuitously. For that, -pedantic is required in addition to -ansi.
-
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.
- -bsd
-
Enforce strict BSD semantics. When the -bsd option is used, the
macro __STRICT_BSD__ is predefined in the preprocessor. Some header files
may notice this macro and refrain from declaring certain functions or
defining certain macros.
- -traditional
-
Attempt to support some aspects of traditional C compilers. Specifically:
-
All extern declarations take effect globally even if they're written
inside a function definition. This includes implicit declarations of
functions.
-
The keywords typeof, inline, signed, const, and volatile aren't
recognized.
-
Comparisons between pointers and integers are always allowed.
-
Integer types unsigned short and unsigned char promote to unsigned int.
-
Out-of-range floating-point literals aren't an error.
-
In the preprocessor, comments convert to nothing at all, rather than to
a space. This allows traditional token concatenation.
-
In the preprocessor, single and double quotation marks are ignored when
scanning macro definitions, so that macro arguments can be replaced even
within a string or character constant. Quotation marks are also ignored
when skipping text inside a failing conditional directive.
- -ObjC
-
Compile a source file that contains Objective-C code (the file can
have either a ".c" or ".m" extension).
- -O
-
Optimize. Optimizing compilation takes somewhat more time, and a lot
more memory for a large function.
-
Without -O, the compiler's goal is to reduce the cost of compilation
and to make debugging produce the expected results. With -O, the compiler
tries to reduce code size and execution time. Some of the -f options
described below turn specific kinds of optimization on or off.
- -g
-
Produce debugging information in GDB format. This option
greatly reduces debugger startup time because the symbol table information
is stored in the executable file.
-
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 didn't 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, this makes it possible to debug
optimized output if necessary.
- -w
-
Inhibit all warning messages.
- -W
-
Print extra warning messages if automatic variables are used without
first being initialized.
-
These warnings are possible only in optimizing compilation, because
they require data flow information that's computed only when optimizing.
They occur only for variables that are candidates for register allocation.
Therefore, they don't occur for a variable that's declared volatile, or
whose address is taken, or whose size is other than 1, 2, 4, or 8 bytes.
Also, they don't occur for structures, unions, or arrays, even when they're
in registers.
- -Wimplicit
-
Warn whenever a function is implicitly declared.
- -Wreturn-type
-
Warn whenever a function is defined with a return type that defaults to
int. Also warn about any return statement with no return value in a
function whose return type isn't void.
- -Wunused
-
Warn whenever a local variable is unused aside from its declaration, and
whenever a function is declared static but never defined.
- -Wall
-
All the above -W options combined.
- -pg
-
Generate extra code to write profile information suitable for the
analysis program gprof.
- -llibrary
-
Search a standard list of directories for a library named
library, which is actually a file named liblibrary.a.
The linker 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.
- -Ldir
-
Add directory dir to the list of directories to be searched for by
-l.
- -nostdlib
-
Don't use the standard system libraries and startup files when
linking. Only the files you specify (plus gnulib) will be passed to the
linker.
- -doptions
-
Make debugging dumps at times specified by options. Here are
the possible options:
r Dump after RTL generation
j Dump after first jump optimization
J Dump after last jump optimization
s Dump after CSE
L Dump after loop optimization
f Dump after flow analysis
c Dump after instruction combination
l Dump after local register allocation
g Dump after global register allocation
m Print statistics on memory usage, at the end of the run
- -pedantic
-
Issue all the warnings demanded by strict ANSI standard C;
reject all programs that use forbidden extensions.
-
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're rejected.
- -fflag
-
Specify machine-independent flags. These are the flags:
- -ffloat-store
-
Don't store floating-point variables in registers. This prevents
undesirable excess precision due to the floating registers keeping more
precision than a double is supposed to have.
-
For most programs, the excess precision does no harm, but a few programs
rely on the precise definition of IEEE floating point. Use -ffloat-store
for such programs.
- -fno-asm
-
Don't recognize asm, inline, or typeof as a keyword. These words
may then be used as identifiers.
- -fno-defer-pop
-
Always pop the arguments to each function call as soon as that function
returns. Normally the compiler (when optimizing) lets arguments accumulate
on the stack for several function calls and pops them all at once.
- -fcombine-regs
-
Allow the combine pass to combine an instruction that copies one register
into another. This might or might not produce better code when used in
addition to -O.
- -fforce-mem
-
Force memory operands to be copied into registers before doing arithmetic
on them. This may produce better code by making all memory references
potential common subexpressions. When they aren't common subexpressions,
instruction combination should eliminate the separate register-load.
- -fforce-addr
-
Force memory address constants to be copied into registers before doing
arithmetic on them. This may produce better code just as -fforce-mem may.
- -fomit-frame-pointer
-
Don't keep the frame pointer in a register for functions that don't need
one. This avoids the instructions to save, set up and restore frame
pointers; it also makes an extra register available in many functions. It
also makes debugging impossible.
- -finline-functions
-
Integrate all simple functions into their callers. The compiler decides
which functions are simple enough to be worth integrating.
-
If all calls to a given function are integrated, and the function is
declared static, then the function normally isn't produced as assembler
code in its own right.
- -fkeep-inline-functions
-
Produce a separate run-time callable version of the function. Do so even
if all calls to the function are integrated and the function is declared
static.
- -fwritable-strings
-
Store string constants in the writable data segment and don't make them
unique. This is for compatibility with old programs that assume they can
write into string constants. Writing into string constants is a very bad
idea; "constants" should be constant.
- -fno-function-cse
-
Don't put function addresses in registers; make each instruction that calls
a constant function contain the function's address explicitly.
-
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 isn't used.
- -fvolatile
-
Consider all memory references through pointers to be volatile.
- -funsigned-char
-
Let the type char default to unsigned, like unsigned charFr,
rather than
signed like signed char.
- -fsigned-char
-
Let the type char default to signed, like signed char.
- -ffixed-reg
-
Treat the register reg as a fixed register; generated code should never
refer to it (except perhaps as a stack pointer, frame pointer or in some
other fixed role).
-
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.
- -fcall-used-reg
-
Treat the register reg as an allocatable register that's clobbered by
function calls. It may be allocated for temporaries or variables that
don't live across a call. Functions compiled this way won't save and
restore the register 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.
- -fcall-saved-reg
-
Treat the register reg as an allocatable register saved by functions. It
may be allocated even for temporaries or variables that live across a call.
Functions compiled this way will save and restore the register reg
if they use it.
-
Never use 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, or
in a register in which function values may be returned.
These options control the ld link editor, which has been modified to
support Mach-O files and shared libraries. See The NeXT System
Reference Manual for more information about Mach-O files and shared libraries.
- -Mach
-
Create a Mach-O executable format file. This is now the default
format, rather than 4.3BSD a.out files.
- -segcreate segment section file
-
Create a segment named segment and a section named section in that
segment containing the contents of file. The known segments __TEXT and
__DATA shouldn't be used as the segment name.
- -Ttext hex-number
-
- -T hex-number
-
Set the start of the text segment to hex-number, which must be a multiple
of 8192. The default starting address of the text segment is 8192.
- -Tdata hex-number
-
Set the start of data to hex-number, which must be a multiple of 8192.
The default starting address of the data segment is the last address of the
text segment rounded up to a multiple of 8192.
- -ident string
-
Create an ident command in the resulting Mach-O output file and place the
string arguments of all -ident options in it.
- -aoriginal-symbol-name:alias-symbol-name
-
Change original-symbol-name
in the input ".o" files to alias-symbol-name in
the final a.out. The original symbol name must not be defined.
- -Z
-
Inhibit the searching of the default directories for -lx arguments.
-
If you add segments to Mach-O files with the -segcreate
flag, the contents
of file-name go into the segment (the cc command also understands this set
of flags). This will also work with atom, the "a.out to Mach-O" converter.
These segments are mapped into the address space of the executable, and the
contents can be read (and written) by the executable. Note that if you
write it, it doesn't go back into the executable. It's just like
initialized data (copy-on-write). It's intended to be used for things such
as the icons and the archive.
FILES
- a.out
-
executable output file
- file.a
-
library of object files
- file.c
-
C source file
- file.m
-
Objective-C source file
- file.i
-
C source file after preprocessing with
cpp(1)
- file.o
-
object file
- file.s
-
assembler source file
SEE ALSO
gdb(1), ld(1)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- FILES
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 17:19:08 GMT, March 25, 2025