cc
PURPOSE
Compiles C programs.
SYNOPSIS
cc [ option ] ... file ...
Ordinary Operation
Extended Functions and Debugging
DESCRIPTION
The cc command runs the C compiler. It accepts files
containing C source code, assembler source code, or
object code and changes them into a form that the com-
puter system can run. cc compiles and assembles source
files and then links them with any specified object
files, in the order listed on the command line. It puts
the resulting executable program in a file named a.out.
The fcc command is a link to cc that compiles programs to
run with the Floating-Point Accelerator. fcc should only
be used on a 032 microprocessor. It automatically uses
the -f flag as well as special versions of the standard
libraries that have been compiled for direct floating-
point applications. Note that programs compiled with fcc
can run only on systems that have installed the Floating-
Point Accelerator.
The vcc command is a link to cc that compiles modules to
be installed in the VRM. Use the vrmfmt command to
convert the a.out file produced by the vcc command to a
VRM-compatible object module. The syntax of this command
is as follows:
vrmfmt infile [outfile]
The default output file name is a.vrm.
The cc command runs the following programs. Each program
processes the source file and then sends the results to
the next program in the sequence:
cpp The macro preprocessor.
ccom0 The first pass of the compiler.
ccomq The intermediate code optimizer (if you specify
the -O flag).
This program provides a variety of optimizations
to the intermediate code, such as removing loop
invariants, eliminating common subexpressions, and
allocating registers. The following cannot be
optimized:
o Functions that call setjmp
o Functions that contain asm statements
If you are compiling a large program and the flow
optimizer runs out of space, the compiler stops
the process and displays a message describing the
problem.
ccom1 The second pass of the compiler.
copt The optimizer (if you specify the -O flag).
as The assembler.
ld The linkage editor.
You can replace any or all of these passes with your own
versions (see the -B and -t flags). Both cc and fcc use
the cc.cfg configuration file, which specifies the
standard runtime, the link options, and the libraries to
be used with each version of the compiler.
Input File Types
The cc command recognizes and accepts as input the fol-
lowing file types:
FILE.C: The name of a C language source file should end
with .c. After cc compiles this source file, it gives
the resulting object file the same name, except that it
ends in .o rather than .c. If you use one command both
to compile and to load a single C program, the compiler
normally deletes the .o file when it loads the program.
If you use the -c flag, the compiler does not delete the
.o file.
FILE.I: The name of a file that contains preprocessed C
source code ends in .i.
FILE.O: The name of an object file should end in .o.
The cc command sends these files to the ld command.
FILE.S: The name of an assembly language source program
should end with .s. After cc assembles this source file,
it gives the resulting object file the same name, except
that it ends in .o rather than .s.
FLAGS
The cc command recognizes several flags. In addition,
flags intended to modify the action of the linkage editor
(ld), the assembler (as), or the preprocessor (cpp) may
also appear on the cc command line. cc sends any flags
it does not recognize to these commands for processing.
The following list includes the most commonly used cpp
flags (-D, -I), and ld flags (-l, -L, -o). See "as,"
"cpp," and "ld" for a complete list of additional flags.
Note: If you use the -l flag, it must be the last entry
on the command line, following any file parameters.
Ordinary Operation
-a Reserves a register for extended
addressing. Use this flag if a com-
piled procedure creates a stack
greater than 32,767 bytes. Because
this flag causes the compiler to
reserve a register for use by the
assembler, it reduces the number of
available registers by one.
-c Does not send the completed object
file to the ld command. With this
flag, the output of cc is a .o file
for each .c or .s file.
-Dname[=def] Defines name as in a #define direc-
tive. The default def is 1.
-E Runs the named C source file through
only the preprocessor and writes the
result to standard output.
-f Generates code that uses the Floating-
Point Accelerator or Advanced
Floating-Point Accelerator. Programs
compiled with this flag will run cor-
rectly only on 032 microprocessors
configured with either of the
Floating-Point Accelerators.
-f2 Generates code that uses the Advanced
Floating-Point Accelerator. Programs
compiled with this flag will run cor-
rectly only on AIX processors config-
ured with the Advanced Floating-Point
Accelerator and an Advanced Processor
Card.
-g Produces additional information for
use with the sdb command (the symbolic
debugger).
-G Indicates that global variables are
volatile. The optimizer (ccomq) makes
fewer transformations when you specify
this flag. To make a particular vari-
able volatile, add the "volatile"
specification to its declaration.
-h Treats files with the suffix .h in the
same way as files with the suffix .c.
-Idir Looks first in dir, then looks in the
directories on the standard list for
#include files with names that do not
begin with / (slash).
-l[key] Searches the specified library file,
where key selects the file libkey.a.
With no key, -l selects libc.a, the
standard system library for C and
assembly language programs. ld
searches for this file in the direc-
tory specified by an -L flag, then in
/lib and /usr/lib. The ld command
searches library files in the order in
which you list them on the command
line.
-Ldir Looks in dir for files specified by -l
keys. If it does not find the file in
dir, ld searches the standard directo-
ries.
-N[ndpt]num Changes the size of the symbol table
(n), the dimension table (d), the con-
stant pool (p), or the space for
building the parse tree (t). Each
table must be changed separately. The
default size of the symbol table is
1500; the default size of the dimen-
sion table is 2000; the default size
for the constant pool is 600; the
default space for the parse tree is
1000.
-oname Assigns name rather than a.out to the
output file.
-O Sends compiler output to the code
optimizers.
-p Prepares the program so that the prof
command can generate an execution
profile. The compiler produces code
that counts the number of times each
routine is called. If programs are
sent to ld, the compiler replaces the
startup routine with one that calls
the monitor subroutine at the start
(see AIX Operating System Technical
Reference for a discussion of this
subroutine), and writes a mon.out file
when the program ends normally.
-P Sends the specified C source file to
the macro preprocessor and stores the
output in a .i file.
-Q! Controls inlining. The following may
be used:
? Shows the reason
for not inlining
in the output
file.
-name,name . . . Does not inline
name.
+name,name . . . Inlines name.
|num Limits the size
increase of the
function in which
inlining occurs to
num intermediate
operations. The
default num is
100.
#num Limits the expan-
sion of an indi-
vidual call to num
intermediate oper-
ators. The
default num is
100.
-@file Reads a list of
forbidden func-
tions from file.
+@file Reads a list of
requested func-
tions from file.
Requesting a function to be inlined
overrides size constraints.
-S Compiles the specified C programs,
storing assembly language output in a
.s file.
-w Prevents printing of warning messages
about functions that cannot be opti-
mized.
-X Produces an assembler listing. This
is stored in a file that has the same
name as the assembler source file but
with the extension .lst instead of .s.
-y[dmnpz] Specifies the rounding mode for
floating-point constant folding.
These modes are specified as follows:
d Disables floating-point con-
stant folding.
m Rounds toward negative
infinity.
n Rounds to nearest whole
number. This is the default
action and applies to con-
stant folding in all appli-
cable passes of the
compiler.
p Rounds toward positive
infinity.
z Rounds toward 0.
-z Uses the libm.a version, or a version
specified by the user, of the fol-
lowing transcendental functions:
acos asin atan atan2 cos exp
log log10 sin sqrt tan
If this flag is not used, the compiler
generates calls to the AIX kernel, or
the Advanced Floating Point Acceler-
ator if possible. For more informa-
tion on libm.a, see math.h in AIX
Operating System Technical Reference.
For more information on the Advanced
Floating Point Accelerator, see fpfp
in AIX Operating System Technical Ref-
erence.
Debugging
-Ffile[:stanza] Uses an alternative file and/or
stanza for cc configuration (see AIX
Operating System Technical Reference
for a discussion of the configuration
file, cc.cfg). If used, this flag
must be the first flag on the command
line.
-v Displays the trace as with -# and
invokes the programs.
-# Displays a trace of the actions to be
taken (for example, invoking the pre-
processor), without actually invoking
any programs.
Extended Functions
-Bprefix Constructs path names for substitute
preprocessor, compiler, optimizer,
assembler, or linkage editor pro-
grams. prefix defines part of a path
name to the new programs. To form
the complete path name for each new
program, cc adds prefix to the
standard program names (see the dis-
cussion of the programs called by
cc). For example, if you enter the
command:
cc testfile.c -B/usr/jim/new
cc calls the following compiler pro-
grams:
1. /usr/jim/newcpp
2. /usr/jim/newccom0
3. /usr/jim/newccom1
4. /usr/jim/newas
5. /usr/jim/newld
Similarly, if you enter the command:
cc testfile.c -B/usr/jim/new/
cc calls the following compiler pro-
grams:
1. /usr/jim/new/cpp
2. /usr/jim/new/ccom
3. /usr/jim/new/ccom1
4. /usr/jim/new/as
5. /usr/jim/new/ld
The default prefix is /lib/o.
-t[pcqgoal] Applies the -B flag instructions for
constructing file names to only the
designated preprocessor (p), compiler
first (c), intermediate code opti-
mizer (q), compiler second (g), opti-
mizer (o), assembler (a), or linkage
editor (l) passes. You can select
any combination of pcqgoal.
The -t flag with no additional p, c,
q, g, o, a, or l designates by
default the preprocessor, compiler
and optimizer programs (see the dis-
cussion of the programs called by
cc).
If you do not specify the -B flag
when you specify the -t flag, the
default file name prefix is /lib/n.
Note: You can specify this prefix
with the -B flag. However, depending
on what combination of the -B and the
-t flags you specify, prefix can have
two possible default values. If you
specify -B but no accompanying
prefix, the default prefix is /lib/o.
If you specify the -t flag without
also specifying the -B flag, the
default prefix is /lib/n.
-Wc,flag1[,flag2 . . . ]
Gives the listed flags to the com-
piler program c; c can be any one of
the values [pcqgoal] discussed with
the -t flag. For example, since both
ld and as recognize a -o flag, use -W
to specify the program to which the
flag is to be sent. That is, -Wl,-o
sends it to ld. -Wa,-o sends it to
as.
EXAMPLES
1. To compile and link a C program, creating an execut-
able a.out file:
cc pgm.c
2. To compile a program, producing an object file to be
linked later:
cc -c pgm.c
This compiles "pgm.c" and produces an object file
named "pgm".o.
3. To compile a program to run on the Floating-Point
Accelerator:
fcc pgm.c
This compiles "pgm.c" using the special libraries
libfc.a and libfm.a instead of the standard libraries
libc.a and libm.a.
4. To view the output of the macro preprocessor:
cc -P -C pgm.c
This creates a file named "pgm".i that contains the
preprocessed program text including comments. To
view this file, use an editor or see "pg" cc passes
the -P and -C flags to the preprocessor. See "cpp"
for more details about them.
5. To predefine macro identifiers:
cc -DBUFFERSIZE=512 -DDEBUG pgm.c
This assigns "BUFFERSIZE" the value "512" and "DEBUG"
the value "1" before preprocessing. cc passes the -D
flag to the preprocessor.
6. To use #include files located in nonstandard directo-
ries:
cc -I/u/jim/include pgm.c
This looks in the directory that contains "pgm.c" for
the #include files with names enclosed in double
quotes ("" ""), then in "/u/jim/include", and then in
the standard directories. It looks in
"/u/jim/include" for #include file names enclosed in
angle brackets ("< >"), then in the standard directo-
ries. cc passes the -I flag to the preprocessor.
7. To optimize the object code and produce an assembler
listing:
cc -S -O pgm.c
This uses the optimizing compiler (-O is minus,
capital oh), and produces an assembler listing in a
file named "pgm".s (-S).
FILES
file.c C source file.
file.o Object file.
file.s Assembler file.
a.out Linked output.
/etc/cc.cfg cc configuration file.
/tmp/ctm* Temporary.
/lib/cpp C preprocessor.
/lib/ccom0 Compiler first pass.
/lib/ccomq Intermediate code optimizer.
/lib/ccom1 Compiler second pass.
/lib/cgen Compiler.
/lib/copt optimizer.
/bin/as Assembler.
/bin/ld Linkage editor.
/lib/crt0.o Runtime startoff.
/lib/mcrt0.o Runtime startoff for profiling.
/lib/libc.a Standard library.
/lib/libfc.a Standard library for use with Floating-
Point Accelerator.
/lib/libm.a Standard math library.
/lib/libfm.a Standard math library for use with
Floating-Point Accelerator.
/lib/librts.a Runtime services.
/usr/include Standard directory for #include files.
/usr/tmp/ctm* Temporary.
RELATED INFORMATION
The following commands: "as," "ld," "cpp," "prof," and
"sdb."
The discussion of cc in AIX Operating System Programming
Tools and Interfaces, in C Language Guide and Reference
and in Assembler Language Reference.
The monitor subroutine, the a.out and cc.cfg files, the
discussion of the Advanced Floating Point Accelerator
(fpfp), and math.h in AIX Operating System Technical Ref-
erence.