cc(1) cc(1)
NAME
cc - C compiler
SYNOPSIS
cc [options] file . . .
DESCRIPTION
The cc command is the interface to the C compilation system.
The compilation system consists of the following conceptual
phases: preprocessing, compiling, optimizing, basic block
profiling, assembling, and linking. The cc command examines
its options and filename suffixes, and then executes the
proper phases with appropriate options and arguments.
The cc command recognizes the following filename suffixes:
.c A file that contains unprocessed C source; all phases
are applicable.
.i A file that contains preprocessed C source; all phases
except for preprocessing are applicable.
.s A file that contains assembly language source; only the
assembling and linking phases are applicable.
other A file that contains input applicable only to the
linking phase. This category commonly includes object
files (.o), archive libraries (.a), and shared object
libraries (.so).
If no options are present, the cc command sends all files
through those phases (as appropriate to their suffixes) as are
necessary to combine them into a dynamically linked executable
with the name a.out in the current directory. If an
intermediate result is requested instead, it is similarly
placed in the current directory, with a filename derived by
replacing the incoming suffix with a suffix appropriate to the
resultant file. If the assembling phase occurs, the cc
command places the object file (.o) in the current directory,
but this file will be removed if a single source file is being
compiled through to an executable. All other intermediate
files are placed in a temporary directory. (The choice of
directory can be controlled with the environment variable
TMPDIR.)
Copyright 1994 Novell, Inc. Page 1
cc(1) cc(1)
An exception to the filename suffix rule is that any file
name, regardless of suffix, will be accepted with the -E
option. This allows the C preprocessor to be invoked as a
standalone tool for use with non-C source files.
The following options are applicable to all phases.
-Q str Controls the inclusion of compilation tool
identification information in the output. If str is y
(the default), then the information will be present;
if str is n, it will not.
-V Causes the cc command and each invoked tool to print
its version information, one per line, on the standard
error output.
-W phase,list
Hands the argument(s) specified by the comma-separated
list (in order) to the single compilation phase named
by phase. An argument in list can include a comma by
escaping it by a preceding \. If more than one
conceptual phase is implemented by a single tool, all
the associated argument lists are passed to the tool.
The phase names are the following:
p preprocessor
0 compiler
2 optimizer
b basic block profiler
a assembler
l linker
Relative to the regular options and arguments passed
to the compilation phase, the location of the
arguments specified by list is unspecified and may
change.
-X str Controls the degree of conformance to the ANSI and ISO
C standards. The option argument str can be one of
the following:
a Specifies standards conformance except that some
required warnings are omitted and the name space is
expanded to include names that are not specified by
the standards. All C constructions behave as
specified in the standards. All implemented
Copyright 1994 Novell, Inc. Page 2
cc(1) cc(1)
language and library extensions beyond the
standards are also available. This is the default.
c Specifies strict standards conformance. Because
the name space of the language and headers is
reduced from that of -Xa, certain extensions (such
as the asm keyword) and some commonly expected
header file declarations are not available. The
latter may be helped by use of -D_POSIX_SOURCE or
-D_XOPEN_SOURCE.
t Specifies standards conformance except where the
semantics differ from ``classic'' C. (See
Kernighan & Ritchie, First Edition.) In addition,
warnings are issued about preprocessing phase
semantic changes such as new escape sequences (like
\x) and any trigraph replacements (like ??!).
Certain potential optimizations available in the
other -X modes are also disabled.
In all -X modes, the compiling phase will warn about
expressions in which the modified promotion rules for
narrower unsigned values may cause an otherwise hidden
behavior change.
-Y str,dir
Uses the directory dir to find the item(s) named by
str. The option argument str is one or more of the
following:
phase Causes the phase (spelled the same as for -W) to
be found in the directory dir. If more than one
conceptual phase is implemented by a single tool
and differing directories are specified for the
phases, it is unspecified which directory is
used.
I Changes the directory searched last for
preprocessing phase include files.
P Changes the linking phase default library search
path to be the colon-separated list of one or
more directories, dir. (More directories can be
added to the front of the path due to other
options.)
Copyright 1994 Novell, Inc. Page 3
cc(1) cc(1)
S Changes the directory in which to find the
implementation's start-up object files.
In addition to the ability to specify the directory in
which to find the various compilation phases, if the
cc command is invoked as prefixcc, then each tool
executed will be similarly prefixed, as will the
filenames for the start-up object files. For example,
if the command ./abccc is invoked with -Ya,../xyz,
then the assembler would be expected to have the
pathname ../xyz/abcas.
The following options are applicable only to the preprocessing
phase. During this phase, the macros _ _STDC_ _ and _ _USLC_
_ are always predefined. While
_ _USLC_ _ always has a positive integer value (which
signifies that a USL C compilation system is being used), _
_STDC_ _ has the value 1 only for -Xc, and the value 0
otherwise.
-A name[(tokens)]
Causes name to be asserted as a predicate associated
with the optional parenthesized tokens as if by a
#assert directive.
-A - Causes all predefined macros (other than those that
begin with __) to be undefined and all preassertions
to be unasserted.
The affected predefined macros and preassertions are
the following:
#define i386 1 /* not present if -Xc */
#define unix 1 /* not present if -Xc */
#assert system(unix)
#assert cpu(i386)
#assert machine(i386)
-C Causes all comments other than on directive lines to
be retained in the output of the preprocessor phase;
otherwise, they are removed.
-D name[=tokens]
Causes name to be defined as a macro to be replaced by
tokens, or by 1 if =tokens is not present, as if by a
#define directive.
Copyright 1994 Novell, Inc. Page 4
cc(1) cc(1)
-E Suppresses all phases but preprocessing, and sends the
result to the standard output. The result will
contain lines similar to preprocessing directives and
can be used for a subsequent compiling phase. The
name of the file being preprocessed may have any
suffix.
-H Causes the pathnames of all files included to be
printed, one per line, on the standard error output.
-I dir Causes dir to be searched for included files whose
names do not begin with / before searching the usual
directories. The directories for multiple -I options
are searched in the order specified.
-P Suppresses all phases but preprocessing, and places
the result in a .i-suffixed file. Unlike -E, the
result will contain no directives. Compiling this
resultant .i file produces an executable whose line
numbers match the .i file instead of the .c file.
-U name Causes name to be undefined as a macro as if by a
#undef directive, even if name is a predefined macro
(including those that begin with __) or is also the
subject of a -D option.
The following options are applicable to all phases except the
preprocessing phase. All options affecting only the linking
phase are also handed to the ld(1) command.
-B str Controls the linking phase library name search
mechanism for subsequent -l options. The option
argument str can be either dynamic (the initial
setting) or static. The order of the -B, -L, and -l
options is significant; see the -l option.
-c Suppresses the linking phase. No produced object
files (.o) are removed.
-d str Determines the mode of the executable result of the
linking phase. If str is y (the default), a
dynamically linked executable is to be produced; if
str is n, the result will be statically linked.
Copyright 1994 Novell, Inc. Page 5
cc(1) cc(1)
-G Causes the linking phase to produce a shared object
instead of an executable.
-g Causes the generation of information that facilitates
symbolic debugging. This option clashes with -O but
has lower precedence: no debugging information is
generated if both are specified.
-K list Enables certain variations in code generation, or
optimization, or linking, or a combination thereof.
For those items in the following list presented in
groups of two or more, the first item is the default
choice, and at most one of each such group will be
effective. The option argument list is a comma-
separated list of one or more of the following items:
PIC Changes code generation to be position-
independent.
thread Specifies whether the program will use the
multi-threading facilities. In threaded mode,
arranges for the appropriate preprocessor
flags to be turned on and for the threading
library to be linked in the correct order.
blended
pentium
i486
i386 Causes code generation specifically tuned to
the selected processor. blended balances the
code generation choices to work well on all
processors. Used only in conjunction with the
-O option.
ieee
no_ieee Controls whether the generated floating point
code strictly conforms to the IEEE floating
point and C standards. ieee specifies strict
conformance. no_ieee permits more aggressive
floating point optimization. It assumes that
the application does not change rounding
modes, does not check for exception
conditions, and does not produce NaNs or
infinities. In this mode, errno might not be
set as often and exceptions may not be raised.
Copyright 1994 Novell, Inc. Page 6
cc(1) cc(1)
no_frame
frame Specifies whether the generated code must use
the %ebp register as the stack frame pointer.
no_frame permits %ebp to be allocated as a
general purpose register, which can cause
debugging stack traces to be unreliable, but
usually produces faster code. Only applies
when the -O option is specified. Unoptimized
code always uses the frame pointer.
host
no_host In hosted mode, the compiler assumes that
function names in the C standards are reserved
and behave as described by the standard. The
compiler will be free to inline such functions
if requested. If no_ieee is also specified,
the compiler assumes that math functions do
not have NaNs or infinities as arguments and
do not produce NaNs or infinities.
no_inline
inline Specifies whether the compiler should perform
function inlining. Inlining may yield better
execution speed at the expense of extra code
size. Only applies if the -O option is
specified.
loop_unroll
no_loop_unroll
Specifies whether the compiler performs loop
unrolling when optimization is enabled (-O).
Loop unrolling may yield better execution
speed at the expense of extra code size.
schar
uchar Specifies whether plain character types are
considered signed or unsigned. The default is
signed.
Multiple -K options have the same effect as if the
separate list arguments were merged into one option.
-L dir Adds dir to the linking phase list of directories to
be searched for subsequent -l options. The order of
the -B, -L, and -l options is significant; see the -l
option.
Copyright 1994 Novell, Inc. Page 7
cc(1) cc(1)
-l str Causes the linking phase to search the library
libstr.so or libstr.a. The order of the -B, -L, and
-l options is significant: A -l option causes the
linker to check first in the directories specified by
preceding -L options (in order) and then in the
directories of the default library search path (-YP).
If -Bdynamic is set at the point of the -l option,
each directory is checked first for libstr.so and then
libstr.a; otherwise, only libstr.a is checked.
-O Enables the optimization phase. This phase clashes
with -g but has higher precedence: no debugging
information is generated if both are specified. This
phase also clashes with -ql but has lower precedence:
the optimization phase is disabled if both are
specified.
-o str Causes the linking phase to place its result in str
instead of a.out.
-p Causes extra code to be generated that counts the
number of calls to each routine. If the linking phase
is enabled, the default library search path (-YP) is
altered to check directories that are intended to
contain similarly instrumented libraries before the
usual directories. Moreover, different start-up
object files are used that arrange to record (in the
file mon.out) the time spent in each routine; see
prof(1).
-q str Causes extra code that instruments the program to be
generated. If str is p, the behavior is the same as
the -p option. If str is l, the basic block profiling
phase is enabled which generates extra code that
counts the number of times each source line is
executed; see lprof(1). If str is f, a flow profile
log is created; see fprof(1). The -O option clashes
with -ql but has lower precedence: the optimization
phase is not enabled if both are specified.
-S Suppresses the assembling and linking phases, and
produces an assembly file (.s-suffixed file).
-v Causes the compiling phase to perform extra syntactic,
semantic, and lint(1)-like checks.
Copyright 1994 Novell, Inc. Page 8
cc(1) cc(1)
-Z str Controls the packing of structures in the compiling
phase. The option argument str is one of the
following:
p1 Selects at least one byte alignment for all
structure members; or, in other words, include no
padding. (This can also be specified as -Zp.)
p2 Selects at least two byte alignment for structure
members of at least two bytes in size.
p4 Selects two byte alignment for two byte sized
structure members and four byte alignment for
larger structure members. This is the default
choice.
The cc command recognizes -e, -h, -u, and -z as linking phase
options with arguments. These, and all other unrecognized
option-like arguments are handed to ld(1).
Finally, the cc command also recognizes the option -#. If one
-# option is present, the cc command will print each tool with
its options and argument just before it is invoked. With two
-# options, the pathname of each tool is also printed; with
three, the invocations are skipped.
FILES
a.out default name of resulting executable
INCDIR last directory to search for include files
LIBDIR/*crt*.o startup code object files
LIBDIR/acomp preprocessor and compiler
LIBDIR/optim optimizer
LIBDIR/basicblk
basic block profiler
BINDIR/as assembler
BINDIR/ld linker
LIBDIR/libc.so dynamic shared standard C library
LIBDIR/libc.a archive standard C library
DIR/libp subdirectory of each LIBPATH entry in which to
check for profiled libraries
INCDIR usually /usr/include
LIBDIR usually /usr/ccs/lib
BINDIR usually /usr/ccs/bin
LIBPATH usually /usr/ccs/lib:/usr/lib
Copyright 1994 Novell, Inc. Page 9
cc(1) cc(1)
TMPDIR usually /var/tmp but can be overridden by the
environment variable TMPDIR.
/usr/lib/locale/locale/LC_MESSAGES/uxcds
language-specific message file [See LANG on
environ(5).]
REFERENCES
as(1), debug(1), ld(1), lint(1), lprof(1), monitor(3C),
prof(1), tmpnam(3S)
Kernighan, B. W., and Ritchie, D. M., The C Programming
Language, Second Edition, Prentice-Hall, 1988
American National Standard for Information Systems -
Programming Language C, X3.159-1989
International Standard ISO/IEC 9899:1990, Programming
Languages - C
International Standard ISO/IEC 9945-1:1990, Information
Technology - Portable Operating System Interface (POSIX) -
Part 1: System Application Program Interface (API) [C
Language]
NOTICES
If a mode choice option (such as -Q or -X) is specified more
than once, generally the last is used.
New code should use -Xa, -Khost and -v; old code is probably
best handled with -Xt and -Kno_host.
For a typical multiuser Intel486 microprocessor-based system,
the fastest code will probably be generated by using the -Xa,
-Kno_ieee, -Kinline, and -O options, and by using the standard
include files such as <string.h>.
Copyright 1994 Novell, Inc. Page 10