cc Command cc
Compiler controller
cc [compiler options] file .... [linker options]
cc is the program that controls compilation of C programs. It
guides files of source and object code through each phase of com-
pilation and linking. cc has many options to assist in the com-
pilation of C programs; in essence, however, all you need to do
to produce an executable file from your C program is type cc
followed by the name of the file or files that hold your program.
It checks whether the file names you give it are reasonable,
selects the right phase for each file, and performs other tasks
that ease the compilation of your programs.
***** File Names *****
cc assumes that each file name that ends in .c or .h is a C
program and passes it to the C compiler for compilation.
cc assumes that each file argument that ends in .s is in Mark
Williams assembly language and processes it with the assembler
as.
cc also passes all files with the suffixes .o or .a unchanged to
the linker ld.
***** How cc Works *****
cc normally works as follows: First, it compiles or assembles the
source files, naming the resulting object files by replacing the
.c or .s suffixes with the suffix .o. Then, it links the object
files with the C runtime startup routine and the standard C
library, and leaves the result in file file. If only one object
file is created during compilation, it is deleted after linking;
however, if more than one object file is created, or if an object
file of the same name existed before you began to compile, then
the object file or files are not deleted.
***** Options *****
The following lists all of cc's command-line options. cc passes
some options through to the linker ld unchanged, and correctly
interprets to it the options -o and -u.
A number of the options are esoteric and normally are not used
when compiling a C program. The following are the most commonly
used options:
-c Compile only; do not link
-f Include floating-point printf
-lname Pass library libname.a to linker
-o name Call output file name
-V Print verbose listing of cc's action
COHERENT Lexicon Page 1
cc Command cc
-A MicroEMACS option. If an error occurs during compilation, cc
automatically invokes the MicroEMACS screen editor. The er-
ror or errors are displayed in one window and the source code
file in the other, with the cursor set to the line number in-
dicated by the first error message. Typing <ctrl-X>> moves
to the next error, <ctrl-X>< moves to the previous error. To
recompile, close the edited file with <ctrl-Z>. Compilation
will continue either until the program compiles without er-
ror, or until you exit from the editor by typing <ctrl-U>
followed by <ctrl-X><ctrl-C>.
-B[string]
Backup option. Use alternate versions of the compiler for
cc0, cc1, cc2, and cc3. If string is supplied, cc prepends
it to the names of the phases of the compiler to form the
pathnames where these are found. Otherwise, cc prepends the
name of the current directory. If a -t option was previously
given, only the parts of the compiler specified by it are af-
fected. Any number of -B and -t options may be used, with
each -t option specifying the passes affected by the subse-
quent -B option. For example, the command
cc -tp2 -Bnew hello.c
compiles hello.c using newcc2 in place of the ordinarily used
/lib/cc2, and using newcpp in place of the ordinarily used
/lib/cpp.
-c Compile option. Suppress linking and the removal of the ob-
ject files.
-Dname[=value]
Define name to the preprocessor, as if set by a #define
directive. If value is present, it is used to initialize the
definition.
-E Expand option. Run the C preprocessor cpp and write its out-
put onto the standard output.
-f Floating point option. Include library routines that perform
floating-point arithmetic. Because the floating-point
routines require approximately five kilobytes of memory, the
standard C library does not include them; the -f option tells
the compiler to include them. If a program is compiled
without the -f option but attempts to print a floating point
number during execution by using the e, f, or g format
specifications to printf, the message
You must compile with -f option for floating point
will be printed and the program will exit.
COHERENT Lexicon Page 2
cc Command cc
-I name
Include option. Specify a directory the preprocessor should
search for files given in #include directives, using the
following criteria: If the #include statement reads
#include "file.h"
cc searches for file.h first in the source directory, then in
the directory named in the -Iname option, and finally in the
system's default directories. If the #include statement
reads
#include <file.h>
cc searches for file.h first in the directories named in the
-Iname option, and then in the system's default directories.
Multiple -Iname options are executed in the order of their of
appearance.
-K Keep option. Do not erase the intermediate files generated
during compilation. Temporary files will be written into the
current directory.
-l name
library option. Pass the name of a library to the linker.
cc expands -lname into /lib/libname.a. If an alternative
library prefix has been specified by the -tl and -Bstring op-
tions, then -lname expands to stringlibname.a. Note that
this is a linker option, and so must appear at the end of the
cc command line, or it will not be processed correctly.
-M string
Machine option. Use an alternate version of cc0, cc1, cc1a,
cc1b, cc2, cc3, as, lib*.a, and crts0.o, named by fixing
string between the directory name and the pass and file
names.
-n Instruct the linker ld to bind the output with separate
shared and private segments, and which each starting on a
separate hardware-segment boundary. This allows several
processes to simultaneously use one copy of the shared seg-
ment. Note that programs linked with this option will run a
little more slowly than if they were not so linked; however,
if a program forks (e.g., kermit) or will be used by more
than one user at a time (e.g., MicroEMACS), this slightly
slower time will be more than offset by the program's being
spared having to read an entire copy of itself from the disk.
-N[p0123sdlrt]string
Name option. Rename a specified pass to string. The letters
p0123sdlrt refer, respectively, to cpp, cc0, cc1, cc2, cc3,
the assembler, the linker, the libraries, the run-time start-
up, and the temporary files.
COHERENT Lexicon Page 3
cc Command cc
-o name
Output option. Rename the executable file from the default
to name. If this option is not used, the executable will be
named after the first .c or .o file on the command line.
-O Optimize option. Run the code generated by the C compiler
through the peephole optimizer. The optimizer pass is man-
datory for the i8086, Z8000, and M68000 compilers, and need
not be requested. It is optional for the PDP11 compiler, but
is recommended for all files except those that consist en-
tirely of initialized tables of data.
-q[p0123s]
Quit option. Terminate compilation after running the
specified pass. The letters p0123s refer, respectively, to
cpp, cc0, cc1, cc2, cc3, and the assembler. For example, to
terminate compilation after running the parser cc0, type -q0.
-Q Quiet option. Suppress all messages.
-S Suppress the object-writing and link phases, and invoke the
disassembler cc3. This option produces an assembly-language
version of a C program for examination, for example if a com-
piler problem is suspected. The assembly-language output
file name replaces the .c suffix with .s. This is equivalent
to the -VASM option.
-t[p01ab23sdlrt]
Take option. Use alternate versions of the compiler phases
and other files specified in the following string. If no
following string is given, the cc uses alternate version of
every phase of the compiler, except the preprocessor. If the
-t option is followed by a -B option, cc prepends the prefix
string named in the -B option to the phases and files named
in the -t option; otherwise, the it looks for the alternate
forms in the current directory.
-U name
Undefine symbol name. Use this option to undefine symbols
that the preprocessor defines implicitly, such as the name of
the native system or machine.
-V Verbose option. cc prints onto the standard output a step-
by-step description of each action it takes.
Vstring
Variant option. Toggle (i.e., turn on or off) the variant
string during the compilation. Variants that are marked on
are turned on by default. Options marked Strict: generate
messages that warn of the conditions in question. cc recog-
nizes the following variants:
-VASM
Output assembly-language code. Identical to -S option, above.
It can be used with the -VLINES option, described below, to
COHERENT Lexicon Page 4
cc Command cc
generate a line-numbered file of assembly language. Default
is off.
-VCOMM
Permit .com-style data items. Default is on.
-VFLOAT
Include floating point printf routines. Same as -f option,
above.
-VLINES
Generate line number information. Can be used with the option
-VASM, described above, to generate assembly language output
that uses line numbers. Default is off.
-VQUIET
Suppress all messages. Identical to -Q option. Default is
off.
-VSBOOK
Strict: note deviations from The C Programming Language, ed.
1. Default is off.
-VSCCON
Strict: note constant conditional. Default is off.
-VSINU
Implement struct-in-union rules instead of Berkeley-member
resolution rules. Default is off, i.e., Berkeley rules are
the default.
-VSLCON
Strict: int constant promoted to long because value is too
big. Default is on.
-VSMEMB
Strict: check use of structure/union members for adherence to
standard rules of C. Default is on.
-VSNREG
Strict: register declaration reduced to auto. Default is on.
-VSPVAL
Strict: pointer value truncated. Default is off.
-VSRTVC
Strict: risky types in truth contexts. Default is off.
-VSTAT
Give statistics on optimization.
-VS
Turn on all strict checking. Default is on.
COHERENT Lexicon Page 5
cc Command cc
-VSUREG
Strict: note unused registers. Default is off.
-VSUVAR
Strict: note unused variables. Default is on.
-V3GRAPH
Translate ANSI trigraphs. Default is off.
***** See Also ***** as, C language, cc0, cc1, cc2, cc3, com-
mands, cpp, ld
The C Language, tutorial
COHERENT Lexicon Page 6