Name
cc - invokes the C compiler.
Syntax
cc [option]... file... [option... file...] [-link[link-
libinfo]]
Description
cc is the C compiler command. It creates executable
programs by compiling and linking the files named by the
filename arguments. cc copies the resulting program to the
file a.out. The file a.out is in COFF format by default.
To specify the generation of standard XENIX files, (OMF
format files), use the -xenix , -x2.3 , or -xout flags. See
the section on creating XENIX binaries in the Xenix
Development and Portability Guide for more information.
Additionally, you can direct the compiler to produce DOS or
OS/2 format binaries by giving the -dos or -os2 flags. Note
that if these flags are present, they override all other
flags that may be given on the command line. Thus, if you
place both the -xenix and the -dos flags on your command
line, the output will be in DOS format. For more information
on developing DOS and OS/2 binaries, see the DOS-OS/2
Development Guide.
The filename can name any C or assembly language source file
or any object or library file. C source files must have a
.c filename extension. Assembly language source files must
have .s or .asm, object files .o, and library files .a
extensions. cc invokes the C compiler for each C source
file and copies the result to an object file whose basename
is the same as the source file but whose extension is .o.
The cc command invokes the AT&T assembler, as , for each
assembly source file that ends with .s, and it invokes the
Microsoft assembler, masm, for each assembly source file
that ends with .asm. The cc command copies the result to an
object file with extension .o. cc ignores object and
library files until all source files have been compiled or
assembled. It then invokes the link editor, ld , and
combines all the object files it has created together with
object files and libraries given in the command line to form
a single program.
Files are compiled as they occur on the command line, and
only flags that are listed before the name of the file on
the command line are taken into account. This makes the
order of files very important. The exception to this rule
are flags to the linker, such as -l, which are taken into
account during linking after all objects to be created are
gathered. Library files are examined only if functions
referenced in previous files have not yet been defined.
Only those functions that define unresolved references are
concatenated. A number of ``standard'' libraries are
searched automatically. These libraries support the
standard C library functions and program startup routines.
Which libraries are used depends on the program's specific
flags and memory model (see the options and ``Memory
Models'' below). By default, the libraries are found in the
directory /lib and their names are prefixed with ``lib'' .
These libraries are generally used for resolving references
during linking. The entry point of the resulting program is
set to the beginning of the standard startup code which then
calls the ``main()'' function of the program.
By default, cc creates binaries with full International
functionality; the library file, libintl, is automatically
included in the link command line, and M_INTERNAT is
automatically defined by cc. The -nointl option cancels
international functionality. For more information, refer to
the section on Developing International Applications.
There are the following options:
-c Creates a linkable x.out object file for each source
file but does not link these files. No executable
program is created.
-compat
Makes an executable file that is binary compatible
across the following systems (as distributed by certain
vendors):
386 UNIX System V Release 3.2
UNIX-286 System V
UNIX-386 System V
UNIX-286 3.0
UNIX-8086 System V
The XENIX libraries are used with this option.
-C Preserves comments when preprocessing a file with -E,
-P, or -EP. That is, comments are not removed from the
preprocessed source. This option may only be used in
conjunction with -E, -P, or -EP.
-CSON, -CSOFF
When optimization (-O) is also specified, these options
enable or disable ``common sub-expression''
optimization.
-d Displays the various passes and their arguments before
they are executed.
-dos Directs cc to create an executable program for MS-DOS
systems. The DOS libraries are used with this option.
-Dname[=string ]
Defines name to the preprocessor as if defined by
#define in each source file. The form ``-Dname'' sets
name to a value of 1. The form ``-Dname=string'' sets
name to the given string. See the -U option for more
information on the default manifest defines.
-E Preprocesses each source file as described for -P , but
copies the result to the standard output. The option
also places a #line directive with the current input
line number and source file name at the beginning of
output for each file.
-EP Preprocesses each source file as described for -P, and
prints the output both to a file and the standard
output -EP does not place a #line directive at the
beginning of the file.
-Fnum
Sets the size of the program stack to num bytes. The
value of num must be given in hexadecimal. The default
stack for the 8086 is variable, starting at the top of
a full 64 Kbyte data segment that grows down until it
reaches data. The default stack for the 80286 is 1000
bytes (0xFFFF hexadecimal). This option does not apply
to the 80386, which has a variable stack.
-Fa, -Faname
Create an assembly source listing in source.asm or the
named file. Continues with the link if requested.
This option performs the same function as the -S
option.
-Fc, -Fcname
Create a merged assembler and C listing in source.L or
in the named file.
-Fename
Names the executable program file name.
-Fl, -Flname
Create a listing file in source.L (or the named file)
with assembly source and object code. Continues with
the link if requested.
-Fm, -Fmname
Instruct the linker to create a map listing in a file
called a.map (or the named file). This file contains
the names of all segments in order of their appearance
in the load module. Use this option only to produce
XENIX compatible binaries.
-Foname
The object filename will be name instead of source.o.
-FPa, -FPc, -FPc87, -FPi, -FPi87
When used in conjunction with -dos or -os2, these
options control the type of floating point code
generated and which library support to use. The
default is -FPi. For more information see the DOS-OS/2
Cross Development Guide.
-Fs, -Fsname
Creates a C source listing in source.S or the named
file.
-g Includes information for the symbolic debugger (sdb)
and for CodeView. (This is equivalent to the -Zi
option.)
-Gc Specifies the alternate calling sequence and naming
conventions used in System V 386 Pascal and System V
386 FORTRAN. There are three keywords that go with this
option. They are fortran, pascal, and cdecl. For more
information about this option, see the C User's Guide.
-Gs Removes stack probe routines. This option reduces
binary size and speeds execution slightly. Use of this
option disables stack checking and stack overflow can
occur without warning or error messages.
-Hnum
Sets the maximum length of external symbols to num.
This option is equivalent to the -nl option.
-help
Prints help menu.
-HELP
Same as -help.
-i Creates separate instruction and data spaces for small
model programs. When the output file is executed, the
program text and data areas are allocated separate
physical segments. The text portion will be read-only
and may be shared by all users executing the file.
This option is implied when creating middle or large
model programs.
-I pathname
Adds pathname to the list of directories to be searched
when an #include file is not found in the directory
containing the current source file or whenever angle
brackets (< >) enclose the filename. If the file
cannot be found in directories in this list,
directories in a standard list are searched.
-J Changes the default mode for the char type to unsigned.
-K Removes stack probes from a program. Stack probes are
used to detect stack overflow on entry to program
routines. Code
generated for the 80386 processor does not require
stack probes, therefore this option has no effect if
-M3 is specified.
-lname
Searches library name for unresolved function
references.
-link
Lets the user specify linker switches at compile time
that are not directly supported by the compiler. This
option must be specified last on the cc command line.
All text (options and filenames) that follows this
option is passed directly to the ld linker. (Note that
all options not recognized by the compiler are passed
to the linker.)
-L Creates an assembler listing file containing assembled
code and assembly source instructions. The listing is
made in a file whose basename is the same as the source
but whose extension is .L. This option suppresses the
-S option.
-LARGE
Invokes the large model passes of the compiler. This
option is included in this release only for backward
compatibility.
-m name
Creates a map file called name. This option is
equivalent to the -Fm option. Use this option only to
produce XENIX compatible binaries.
-M string
Sets the program configuration. This configuration
defines the program's memory model, word order, and
data threshold. It also enables C language
enhancements such as advanced instruction set and
keywords. Note that the number specifying the CPU type
(0, 1, 2, or 3) must be given before the letter
specifying the size model of the program. For example,
to compile the program to be large model 286, the flag
should be constructed as follows:
-M2l
The string may be any combination of the following
(``s'', ``m'', ``l'', and ``h'' are mutually
exclusive):
a Restricts the language to ansi specifications.
c Creates a compact model program.
For 286 compilations only.
s Creates a small model program (default).
m Creates a middle model program.
For 8086/286 compilations only.
l Creates a large model program.
For 8086/286 compilations only.
h Creates a huge model program.
For 286 compilations only.
e T{ Enables the far, near, huge, pascal, and
fortran keywords. Also enables certain non-ANSI
extensions necessary to ensure compatibility with
existing versions of the C compiler (this applies
only to versions of the C compiler that support ANSI
C).
0 Enables 8086 code generation. The ``s'', ``m'', and
``l'' specifiers are valid here.
1 Enables 186 code generation. The ``s'', ``m'',
``l'', and ``h'' specifiers are valid here.
2 Enables 286 code generation for compiled C source
files. The ``s'', ``m'', ``l'', and ``h''
specifiers are valid here.
3 Enables 386 code generation. The ``m'', ``l'', and
``h'' specifiers are invalid here.
b Reverses the word order for long types. High order
word is first. Default is low order word first.
t num Sets the threshold for the size of the largest data
item in the data group to num. Default is 32,767.
This option can only be used in large model
programs.
d Instructs the compiler not to assume register SS=DS.
f Enables software floating point that does not exist
in UNIX. Useful when compiling object files to be
linked on MS-DOS.
Note that specifying CPU type with 0, 1, or 2 produces XENIX
files and uses the XENIX libraries appropriate to the model size.
See the -xenix option for more information.
-n Sets pure text model. Pure text without separate
instruction and data space is only supported for 80386
binaries. For 8086, 80186, or 80286 binaries this
option is equivalent to the -i option and will give a
warning that it is setting -i when used.
-nl num
Sets the maximum length of external symbols to num.
Names longer than num are truncated before being copied
to the external symbol table.
-nointl
Directs cc to create a binary that does not include the
international functionality.
-ND name
Sets the data segment name for each compiled or
assembled source file to name. If -ND is not given, the
name ``_DATA'' is used.
In large model programs (-Ml) the -ND option can only
be used on ``leaf modules'' - those that make no calls
to routines in another segment.
-NM name
Sets the module name for each compiled or assembled
source file to name. If not given, the filename of each
source file is used.
-NT name
Sets the text segment name for each compiled or
assembled source file to name. If not given, the name
``module_TEXT'' is used for middle model and ``_TEXT''
for small model programs. This option should not be
used on 386 code.
-o filename
Defines filename to be the name of the final executable
program. This option overrides the default name a.out.
Filename can not end in .o or .c.
-os2
Directs cc to create an executable program for OS/2.
OS/2 libraries are used with this option.
-O string
Invokes the object code optimizer. The string consists
of one or more of the following characters:
d Disables most optimization.
a Relaxes alias checking.
s Optimizes code for space.
t Optimizes code for speed.
i Expands certain intrinsic functions inline.
x Performs maximum optimization. Equivalent to
-Oactli.
c Eliminates common expressions. (386 only)
l Performs various loop optimizations. (386 only)
p Precision optimization.
-p Adds code for program profiling. Profiling code counts
the number of calls to each routine in the program and
copies this information to the mon.out file. This file
can be examined using the prof(CP) command.
-pack
Packs structures. Each structure member is stored at
the first available byte, without regard to int
boundaries. Although this will save space, execution
will be slower because of the extra time required to
access 16 bit members that begin on odd boundaries.
-P
Preprocesses each source file and copies the result to
a file whose basename is the same as the source but
whose extension is .i.
-r Performs an incremental linking action.
-s Instructs the linker to strip the symbol table
information from the executable output file.
-S
Creates an assembly source listing in a file whose
basename is the same as the source but whose extension
is .asm. It should be noted that this file is in MASM
format. This option performs the same function as the
-Fa option.
-Ss -St
Sets subtitle (-Ss) and title (-St) for source listings
and bypasses the linking operations of cc.
-SEG num
Sets the maximum number of segments that the linker can
handle to num, which can range from 1 to 1024. If 1024
is too small, use the -NT option to reduce the number
of different segment names.
-Tc Tells cc that the given file is a C source file. Use
this option if the C source file does not have the .c
filename extension.
-u Eliminates all manifest defines. Also see -U.
-U definition
Removes or undefines the given manifest define. The
manifest defines are as follows:
M_I86
M_XENIX
M_UNIX
M_SYS3 or M_SYSIII
M_SYS5 or M_SYSV
M_BITFIELDS
M_WORDSWAP
M_SDATA or M_LDATA
M_STEXT or M_LTEXT
M_I8086 or M_I186 or M_I286 or M_I386
M_I86SM or M_I86MM or M_I86LM
M_INTERNAT
i386
unix
-Vstring
This option allows you to place a text string in your object file. Typically,
a copyright notice or the version of the program is specified here.
string must be enclosed within double quotation
marks if it contains blank spaces or quotation marks. A backslash
character must also precede any quotation marks within the string.
-w
Prevents compiler warning messages from being issued.
Same as ``-W 0''.
-W num
Sets the output level for compiler warning messages. If
num
is 0, no warning messages are issued. If 1, only warnings
about program structure and overt type mismatches are issued.
If 2, warnings about strong typing mismatches are issued.
If 3, warnings for all
automatic conversions are issued.
This option does not affect compiler error message output.
-xenix
For
XENIX
Cross Development, this option produces
XENIX
programs (in OMF format) using the
XENIX
libraries and
include files. These resulting programs are compatible
with
XENIX
386 System V OS. If used in conjunction with the
-M2
option, it is compatible with both 286 and 386 System V.
User libraries that are used for
XENIX
Cross Development must be in
ranlib(CP)
format; that is, the first member must be named
__.SYMDEF,
which is a dictionary for the library.
-x2.3
This option is equivalent to the
-xenix
option, but it additionally includes
the extended functions available with
XENIX
System V 386 release 2.3. When used in conjuction with
-M2,
this option produces
XENIX
System V 286 2.3 compatible files.
-X
Removes the standard directories from the list of
directories to be searched for #include files.
-z
Displays the various passes and their arguments
but does not execute them.
-Za
Restricts the language to ansi specifications. This option
is equivalent to the
-Ma
option.
-Zd
Includes line number information in the object file.
-Ze
Enables the far, near, huge, pascal, and fortran keywords.
This option is equivalent to the
-Me
option.
-Zg
Generates function declarations from function definitions
and writes declarations to standard output-omits p2, p3,
and ld.
-Zi
Includes information used by the symbolic debugger (sdb)
and by CodeView in the output file.
(This is equivalent to the -g option.)
-Zl
Removes default library information from the object file.
-Zpn Packs structure members in memory. Allocates alignment to 1
(for 8086 processors). The
n
argument can be
1,
2,
or
4,
where
1 allocates alignment to 1.
2 allocates alignment to 2 (default for 80286 programs).
4 allocates alignment to 4 (default for 80386 programs).
-Zs
Performs syntax check only-omits calling p2, p3, and ld.
Many options (or equivalent forms of these options)
are passed to the link editor as the last phase
of compilation. The
-M
option with the ``s'', ``m'', and ``l'' configuration
options are passed to specify memory requirements. The
-i,
-F,
and
-p
are passed to specify other
characteristics of the final program.
The
-D and -I
options may be used several times on the
command line. The
-D
option must not define the same name
twice. These options affect subsequent source files only.
Memory Models
These memory models are used for XENIX Cross Development
only. cc can create programs for five different memory
models: small, middle, compact, large, and huge. In
addition, small model programs can be pure or impure. On
models allow programs with code or data larger than 64K
bytes. Since the 80386 can address segments larger than 64K
bytes, the middle, large and huge models are not supported
on the 80386.
Impure-Text Small Model
These programs occupy one 64K byte physical segment in
which both text and data are combined. cc creates
impure small model programs by default. They can also
be created using the -Ms option.
Pure-Text Small Model
These programs occupy two 64K byte physical segments.
Text and data are in separate segments. The text is
read-only and may be shared by several processes at
once. The maximum program size is 128 Kbytes. Pure
small model programs are created using the -i and -Ms
options.
Middle Model
These programs occupy several physical segments, but
only one segment contains data. Text is divided among
as many segments as required. Special calls and
returns are used to access functions in other segments.
Text can be any size. Data must not exceed 64K bytes.
Middle models programs are created using the -Mm
option. These programs are always pure.
Compact Model
This model of program has a maximum of 64K of text, but
multiple segments of data. Data can be any size, but
text must not exceed 64K. Compact model programs are
created with the -Mc option.
Large Model
These programs occupy several physical segments with
both text and data in as many segments as required.
Special calls and returns are used to access functions
in other segments. Special addresses are used to
access data in other segments. Text and data may be
any size, but no data item may be larger than 64K
bytes. Large model programs are created using the -Ml
option. These programs are always pure.
Huge Model
These programs occupy several physical segments with
both text and data in as many segments as required. It
is possible to allow a data construct that spans 64K
byte segments. This implementation imposes limits on
the way the data construct is put together and where it
is located in memory. Huge model programs are created
using the -Mh option. These programs are always pure.
Small, middle, large and huge model object files can only
be linked with object and library files of the same model.
It is not possible to combine small, medium, large, and
huge model object files in one executable program. cc
automatically selects the correct small, middle, large, or
huge versions of the standard libraries based on the
configuration option. It is up to users to make sure that
all of their own object files and private libraries are
properly compiled in the appropriate model.
The special calls and returns used in middle, large, and
huge model programs may affect execution time. In
particular, the execution time of a program which makes
heavy use of functions and function pointers may differ
noticeably from small model programs.
In middle, large, and huge model programs, function
pointers are 32 bits long. In large and huge model
programs, data pointers are 32 bits long. Programs making
use of such pointers must be written carefully to avoid
incorrect declaration and use of these variables.
The -NM, -NT, and -ND options may be used with middle,
large, and huge model programs to direct the text and data
of specific object files to named physical segments. All
text having the same text segment name is placed in a
single physical segment. Similarly, all data having the
same data segment name is placed in a single physical
segment.
cc reads /etc/default/cc to obtain information about default
options and libraries. The default file may contain lines
beginning with the following 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.
cc always searches for a file in /etc/default that matches
the last component of the pathname by which cc was invoked.
Thus by linking cc to several different names and invoking
it by those names, different defaults can be selected.
An example /etc/default/cc file follows:
FLAGS= -M2
LIBS= -lx
This invokes the large model versions of the compiler passes
to generate 286 code with far and near keywords enabled, and
includes libx.a on all links.
Files
/bin/cc Driver
/lib/p1, p2, p3 286 compiler passes
/lib/386/c_1p, p2_386, p3_386 386 compiler passes
/lib/*.a Standard libraries
/etc/default/cc Default options and libraries
See Also
ar(CP), ld(CP), lint(CP), machine(HW), masm(CP), ranlib(CP),
C User's Guide, C Library Guide, and C Language Reference
Notes
Error messages are produced by the program that detects the
error. These messages are usually produced by the C
compiler, but may occasionally be produced by the assembler
or the link loader.
All object module libraries must have a current ranlib
directory. The user must make sure that the most recent
library versions have been processed with ranlib(CP) before
linking. If this is not done, ld cannot create executable
programs using these libraries.
Standards Conformance
cc is conformant with:
AT&T SVID Issue 2, Select Code 307-127;
and The X/Open Portability Guide II of January 1987.
(printed 6/18/89)