cc(CP)
cc --
C compiler and preprocessor
Syntax
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.
.S-
A file that contains assembly language source, and also
contains C-style preprocessor directives.
Only the preprocessor, 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.)
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 cc command operates in two modes, UDK mode and OSR mode.
Some cc options and command behavior
will depend on which mode is being used.
See the
-K udk | osr options,
described below, as well as the
Compatibility
section.
The following options are applicable to all phases.
-o str-
Uses str as the name of the output file instead of the default name.
With no options this renames the a.out executable.
With -c this renames the generated .o object file.
With -S this renames the generated .s assembly file.
With -P this renames the generated .i preprocessed source
file file.
The -o option has no effect in conjunction with the
-E option.
-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 language and library extensions beyond the standards
are also available.
This is the default.
b-
Like a, except that the keywords inline
and restrict are not recognized as keywords.
c-
Specifies strict conformance to ISO/IEC 9899:1990 (C89).
As such, -Xc will cause inline
and restrict not to be taken as keywords (like -Xb),
and will issue one-time use warnings at the first occurrence of
pure syntactic extensions. Examples of these are compound literals,
intermixed declarations and statements in a block, and flexible array
structure members.
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.)
``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.
-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 predefined macros specified in the C standards) to be undefined and all preassertions to be unasserted.
See the
Predefined Macros and Preassertions
section below for details.
-a api-
In OSR mode only, specify the source-level API when compiling
a source file. In SCO OpenServer Release 6, this option is present only for
compatibility with existing application source bases, and
affects only the predefined macros emitted by the compiler.
The option argument
api
can be one of the following:
ansi,
ods30 (same as
xpg4plus in SCO OpenServer),
posix,
xpg4,
xpg4plus,
all
(same as
xpg4plus ).
The predefined macros controlled by this
option are listed in the Predefined Macros and Preassertions
section below.
-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.
-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.
If a .S-suffixed file is being compiled, the result will
be placed in a .s-suffixed file rather than .i-suffixed.
-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(CP)
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.
-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 higher precedence:
debugging information is generated if both are specified.
-i-
Causes the linking phase to omit inclusion of the crti.o
and crtn.o startup code object files when producing a
shared object. This is useful when you are supplying your
own _init and _fini sections for the shared object.
-J-
In OSR mode only, this is a synonym for
-K uchar.
-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.
-lthread should not be used.
threadT-
Causes the same effect as -Kthread, except that
libthreadT (tracing) is linked.
If -Kthread and -KthreadT are specified on the command
line, -KthreadT will be used and a warning will be issued.
-lthreadT should not be used.
pthread-
Causes the same effect as -Kthread, except that in
addition POSIX threads semantics are enabled at runtime
for the
fork(S),
raise(S),
thr_exit(THREAD),
and
thr_exit(PTHREAD),
calls. -lpthread is an acceptable
synonym for -Kpthread.
dollar-
Specifies that the compiler should allow the character $
to be used in identifiers. Since this usage is an extension to the
ANSI/ISO C Standard, use of this option with -Xc will result in
a warning diagnostic
on the first usage of $ in an identifier.
This option may be
needed when porting code from other systems.
blended-
pentium-
pentium_pro-
i486-
i386-
Causes code generation specifically tuned to the selected Intel®
microprocessor.
blended (the default) balances the code generation choices to
work well on
all these processors.
pentium_pro optimizes for all Intel Pentium® Pro-based
processors such as the Pentium II.
Used only in conjunction with -O.
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.
alloca-
no_alloca-
Specifies whether the compiler generates calls to
alloca(S)
inline or not. The default is to inline,
unless -Xc is specified, in which
case the default is to not inline.
Note that calling alloca() within some other function call's
argument expression may well result in broken code if the
alloca() is *not* generated inlined.
When inlined, alloca() works in all situations.
no_frame-
fixed_frame-
frame-
Specifies the stack frame layout strategy the compiler is permitted to
use.
frame uses the ``%ebp'' register
as a dedicated stack frame pointer.
fixed_frame and no_frame
represent alternate stack layouts:
both permit ``%ebp'' to be allocated as a
general purpose register, which
usually produces faster code, but in rare
instances may cause debugging
stack traces to fail. Between the two, fixed_frame
saves instructions at the expense of stack space, while
no_frame does the reverse. fixed_frame
is advantageous for the Intel Pentium Pro processor architecture,
and is the default when -Kpentium_pro is specified.
Otherwise, no_frame is the default.
This option only applies
when the -O option is specified; unoptimized
code always uses the frame pointer layout.
no_args_in_regs-
args_in_regs-
Specifies whether the compiler may perform argument
passing in registers, which produces faster code.
This is done for certain types of
calls within a translation unit, and only when -O
is specified.
A consequence of this option is that function breakpointing in
debugging,
and argument information in debugging
stack traces, may be unreliable.
-Kargs_in_regs clashes with inlining but has lower precedence;
no argument passing in registers is done if both are specified.
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.
Similarly, the C99 inline function specifier will cause
the compiler to attempt to replace invocations of such functions
with an inline substitution only when 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.
udk-
osr-
Specifies the mode for the
cc command,
either UDK or OSR mode. The default mode
depends on which
cc command
is invoked:
/usr/ccs/bin/cc
(or
/usr/bin/cc)
defaults to UDK mode;
/osr5/usr/ccs/bin/cc
to OSR mode.
The mode determines the application binary
interface (ABI) that the generated compile
code will follow: the SVR5/UDK ABI specified
by the "System V Application Binary Interface
Intel386 (TM) Processor Supplement" or the
SCO OpenServer Release 6 ABI. All object files linked
together within a single process must be built
with the same ABI; no mixing is permitted.
The mode also determines where the
cc command
will look for its binary parts, include files,
libraries, and start-up routines (
BINDIR,
INCDIR,
LIBDIR,
LIBPATH ).
Finally, the mode determines
in some cases how the
cc command
processes certain options
no_udk-
The system uses certain heuristics in distinguishing
between binaries compiled for SCO OpenServer using the SCO OpenServer ABI
and binaries compiled for UnixWare or SCO OpenServer Release 6
using the SVR5/UDK ABI. These heuristics can fail
in rare cases. On UnixWare, the
-K udk
option (which is otherwise unnecessary) can be used
in cases when the heuristics break down. It instructs
the link-editor to add a special mark to a binary object
to positively identify it as a binary compiled by the
UnixWare compiler and intended to be able to run on
UnixWare and SCO OpenServer Release 6.
-K no_udk
indicates that no special mark should be inserted.
Identical marks may also be generated separately
by the elfmark(CP) command
When linking on SCO OpenServer and passing the
-Wl, -fosr5
option to
ld(CP),
the
-K no_udk
option must be used.
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.
-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.
Avoid specifying -lc;
cc
will ensure that libc
is linked
in the proper order. Linking libc in the wrong order may
cause incorrect execution behavior. If you do specify -lc,
make sure there are no other dynamic libraries specified
after it.
Do not specify -lC; C++ links must be done with
CC(CP).
Use -Kthread (or -KthreadT)
instead of -lthread (or -lthreadT) when linking with
the threads library. Using -lthread
(or -lthreadT) directly may cause incorrect
execution behavior.
In OSR mode only,
libcrypt ,
libgen ,
and
libc ,
in that order,
are automatically linked against, rather than just
libc.
-O-
Enables the optimization phase.
This phase clashes with -g but has lower precedence:
the optimization phase is disabled if both are specified.
This phase also clashes with -ql but has lower precedence:
the optimization phase is disabled if both are specified.
-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(CP).
-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(CP).
If str is ``f'', a flow profile log is created; see
.fprof(CP)
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(CP)-like
checks.
-w-
Causes the compiler to suppress warning messages.
-Z str-
Controls the packing of ``full-size'' structure members in the compiling phase.
Bit field packing is not affected by this option.
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, -R, -u, and -z
as linking phase options with arguments.
These, and all other unrecognized option-like arguments
are handed to
ld(CP).
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.
Default Options
In OSR mode only, the
cc
command reads /etc/default/cc to obtain
information about customized default options and libraries.
The default file may contain lines beginning with the
patterns FLAGS= and LIBS=.
Any parameters following the FLAGS= pattern are treated
by cc as if they had been specified at the start
of the cc command line.
Parameters following the LIBS= pattern are treated as if
they had been specified at the end of the command line.
This option is intended for, but not restricted to, the
specification of additional libraries.
If cc is invoked as prefixcc, it
always searches for the file
/etc/default/prefixcc
to retrieve information about the customized default options and libraries.
Thus by linking cc to several different names and
invoking it by those names, different defaults can be selected.
The only exception is when prefix is u, that is, when
cc is invoked as ucc: ucc also
retrieves defaults from the file /etc/default/cc.
CCFLAGS-
The CCFLAGS environment variable can be
used to set additional cc options.
These options
are processed by the compiler driver before any command-line
arguments.
The CCFLAGS variable allows you to override options which
are set using the FLAGS= pattern
in /etc/default/cc, and may itself be
overridden by options you specify on the command line.
CCLIBS-
The CCLIBS variable is similar to CCFLAGS,
except that you may use CCLIBS to override options which
are set using the LIBS= pattern in /etc/default/cc.
Predefined Macros and Preassertions
In both UDK and OSR modes, the following macros are
predefined with these values, regardless of whether the
-A -
option is specified:
__DATE__ "Mmm dd yyyy"
__FILE__ "current pathname"
__LINE__ current line number
__TIME__ "hh:mm:ss"
__STDC__ by default 0; 1 if -Xc
__STDC_HOSTED__ by default 1; 0 if -Kno_host
__STDC_VERSION__ 199409L
__STDC_IEC_559__ 1
__STDC_IEC_559_COMPLEX__ 0
__STDC_ISO_10646__ 199712L
In both UDK and OSR modes, the following macros
are predefined with
these values, and these preassertions are made, unless the
-A -
option has been specified:
__USLC__ 1
__SCO_VERSION__ VvvYYYYMML
V major version of the compiler
vv the minor version
YYYY year of compiler release
MM month of compiler release
i386 1 but not present if UDK mode -Xc
unix 1 but not present if UDK mode -Xc
#assert system(unix)
#assert cpu(i386)
#assert machine(i386)
#assert model(ilp32)
In OSR mode only, the additional following
macros are predefined with these values, unless the
-A -
option has been specified:
_SCO_DS 2
_SCO_DS_LL 1
__OPENSERVER__ 507
__unix 1
__i386 1
_SCO_ELF 1
In OSR mode only, the further additional following
macros may be predefined, depending on the value of the
-a api
option:
API
Manifest ansi posix xpg4 xpg4plus
_POSIX_C_SOURCE - 2 - -
_POSIX_SOURCE - 1 - -
_SCO_ODS_30 - - - -
_STRICT_ANSI 1 - - -
_XOPEN_SOURCE - - 1 -
_STRICT_NAMES 1 1 1 1
Finally, for additional backward compatibility in OSR mode,
the following predefined macros are also emitted for the
default
-a xpg4plus
api only.
Each has the value 1:
_M_I86
_M_I86SM
_M_SDATA
_M_STEXT
_M_BITFIELDS
_M_INTERNAT
_M_SYS5
_M_SYSV
_M_SYS3
_M_SYSIII
_M_WORDSWAP
_M_I386
_M_UNIX
_M_XENIX .
Files
a.out-
default name of resulting executable
INCDIR-
last directory to search for include files
LIBDIR/crt.o-
startup code object files
LIBDIR/libcrt.a-
runtime support archive
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
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(M).]
LIBDIR/values-X*.o-
runtime objects used to implement the -X option
References
as(CP),
debug(CP),
elfmark(CP),
fprof(CP),
ld(CP),
lint(CP),
lprof(CP),
monitor(S),
prof(CP),
tmpnam(S)
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 9899:1999,
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]
Standards compliance
The C language conforms to the updated C standard (C99),
ISO/IEC 9899:1999, except for two major exceptions and two
minor ones. The main unimplemented features are complex
arithmetic and variable length arrays. The former also
means that there is no <complex.h> header.
The minor items are the return value for
snprintf(S)
when the destination
array is not long enough (the C99-conforming functions are
provided, but are spelled _xsnprintf() and
_xvsnprintf()),
and some header name space issues. The latter means that
many of the new names added by C99 to existing headers will
not be visible when using -Xc.
Compatibility
A compatibility
libc
is provided that allows applications compiled
using this compiler to run with earlier UnixWare 7 releases.
See
Intro(S).
The -Xb option removes recognition of only the two new keywords
restrict and inline. All the other new keywords
(for example, _Bool) will continue to be recognised.
Source code built under the SCO OpenServer Release 5
Development System C compiler may require modification if recompiled
in UDK mode, due to differences in the OSR and UDK mode operating
system API sets. Note that you may be recompiling in UDK mode
without realizing it, because simply invoking cc
will usually result in it being found in /usr/ccs/bin/cc
or /usr/bin/cc
and from those locations cc defaults to UDK mode.
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.
Preprocessing for .S-suffixed assembly source files will not
generate the extra tokenizing whitespace that is inserted when
compiling C language source files.
All predefined macros and assertions present for C preprocessing
are also present for .S source file preprocessing.
These can be used to distinguish among different IA-32 assembly
language dialects.
© 2005 Commands for Programming (CP)
SCO OpenServer Release 6.0.0 -- 02 June 2005