DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

cc(CP)


cc -- C compiler and preprocessor

Syntax

cc [options]... file... [options]... file...

Description

The cc(CP) command is the interface to the C compilation system. It examines the options and filename suffixes of its file arguments, then executes the proper compiler passes with appropriate options and arguments. The default filename of the resulting executable is a.out, which can be changed through option -o.

This C compilation system decouples the C language it understands, the source-level Application Programming Interface (API) it uses in compiling source files, and the object file format intended for the run time environment from each other, and each may be selected independently of the other two. The default C language dialect supported by this C compilation system is an extended ANSI C; use option -X to select a different dialect. The default source-level API is an extended XPG4; use option -a to select a different API. The default object file format is Common Object File Format (COFF); use option -b to change it.

The compilation system consists of the following conceptual phases:

The actual compiler passes do not necessarily coincide with these conceptual phases (see option -W or -Y for more information).

The filename suffixes recognized by cc and the associated applicable compilation phases are:


.c
A file that contains unprocessed C source; all phases are applicable.

.i
A file that contains preprocessed C source; all phases except preprocessing are applicable.

.s
A file that contains assembly language source; only the assembling and linking phases are applicable.

.a, .o, .so
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 its input files through all applicable phases (as appropriate to their suffixes) as are necessary, combines the output into a statically linked COFF executable, and puts the executable, a.out, in the current directory. The file permissions of the executable are set to:

S_IRWXO | S_IRWXG | S_IRWXU

Object files (.o files) are normally saved in the current directory if the assembling phase occurs. The object file is removed only if a single source file is being compiled through to an executable. 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. All other intermediate files are placed in a temporary directory and removed upon termination of the cc command. The choice of this temporary directory can be controlled with the environment variable TMPDIR.

The compiler uses the following default options when no options are given:


-a xpg4plus

-b coff

-Qy

-Xa

-w1

-Zp4
If only -b elf is specified, the following options are also default:

-Bdynamic

-dy
These default options may be overridden by options specified in the file /etc/default/cc. See ``Default options''.

Options

These are all the available options:


-#, -i
Turn on driver debugging. Print out each command with its options and arguments as invoked by cc before the command is executed.

-##, -ii
Print out the full pathname of each command, in addition to the command, its options and arguments as invoked by cc before the command is executed.

-###, -iii
The same as -##, except that the command is not executed.

-a api
Specify the source-level API when compiling a source file. This option affects only the manifest defines and header files, not how the compiler treats the C language itself. Use option -X dialect to change the default C language dialect; use option -b to change the default object file format.

The option argument api (case is not significant) can be one of the following:


ansi
Select the moderately strict ANSI C API. All conforming programs compile under this environment. Various names reserved to the implementation name space are visible in the environment, and no diagnostics are issued if the program uses these names.


CAUTION: Even when the option -a ansi is used, it is still possible to go outside the ANSI C API by including header files that are not defined under the ANSI C standard.


ods30
This is very similar to xpg4plus (see the following). It supports some compatible modifications to xpg4 behavior so that most well formed programs that compile under older C compilers should still compile.

posix
Select the moderately strict POSIX 1004.1 and 1004.2 API. This has the same characteristics and limitations as the API selected through -a ansi, except that it conforms to POSIX standards.

xpg4
Select the moderately strict XPG4 API. This has the same characteristics and limitations as the API selected through -a ansi, except that it conforms to the API specified in System Interfaces and Headers, issue 4 by X/Open (XPG4).

xpg4plus
Select the extended XPG4 API. This is the default. Except for the name space pollution necessary for the functionality beyond that of the XPG4 standard, it is compliant with the XPG4 standard.


NOTE: For backward compatibility, api can also be one of xpg3 and xpg3plus, which are treated as xpg4 and xpg4plus respectively. A warning is issued if one of xpg3 and xpg3plus is used, however.

The following table shows the defined values of manifests for each chosen API. A - entry indicates that the manifest is undefined for that particular API.

      API  
Manifest ansi ods30 posix xpg4 xpg4plus  
_POSIX_C_SOURCE - - 2 - -  
_POSIX_SOURCE - - 1 - -  
_SCO_ODS_30 - 1 - - -  
_STRICT_ANSI 1 - - - -  
_XOPEN_SOURCE - - - 1 -  

                 |                API
 Manifest        | ansi   ods30   posix   xpg4   xpg4plus
 _POSIX_C_SOURCE |  -       -       2      -        -
 _POSIX_SOURCE   |  -       -       1      -        -
 _SCO_ODS_30     |  -       1       -      -        -
 _STRICT_ANSI    |  1       -       -      -        -
 _XOPEN_SOURCE   |  -       -       -      1        -
For backward compatibility, the following manifests are also provided in this release.

      API  
Manifest ansi ods30 posix xpg4 xpg4plus ods30
M_I86 - 1 - - - 1
M_I86SM - 1 - - - 1
M_SDATA - 1 - - - 1
M_STEXT - 1 - - - 1
M_BITFIELDS - 1 - - - 1
M_INTERNAT - 1 - - - 1
M_SYS5 - 1 - - - 1
M_SYSV - 1 - - - 1
M_SYS3 - 1 - - - 1
M_SYSIII - 1 - - - 1
M_WORDSWAP - 1 - - - 1
_M_I86 - 1 - - 1 1
_M_I86SM - 1 - - 1 1
_M_SDATA - 1 - - 1 1
_M_STEXT - 1 - - 1 1
_M_BITFIELDS - 1 - - 1 1
_M_INTERNAT - 1 - - 1 1
_M_SYS5 - 1 - - 1 1
_M_SYSV - 1 - - 1 1
_M_SYS3 - 1 - - 1 1
_M_SYSIII - 1 - - 1 1
_M_WORDSWAP - 1 - - 1 1
i386 - 1 - - 1 1
unix - 1 - - 1 1
M_I386 - 1 - - 1 1
M_UNIX - 1 - - 1 1
M_XENIX - 1 - - 1 1
_STRICT_NAMES 1 - 1 1 1 -

               |                API
 Manifest      | ansi   ods30   posix   xpg4   xpg4plus   ods30
 M_I86         |  -       1       -      -        -       1
 M_I86SM       |  -       1       -      -        -       1
 M_SDATA       |  -       1       -      -        -       1
 M_STEXT       |  -       1       -      -        -       1
 M_BITFIELDS   |  -       1       -      -        -       1
 M_INTERNAT    |  -       1       -      -        -       1
 M_SYS5        |  -       1       -      -        -       1
 M_SYSV        |  -       1       -      -        -       1
 M_SYS3        |  -       1       -      -        -       1
 M_SYSIII      |  -       1       -      -        -       1
 M_WORDSWAP    |  -       1       -      -        -       1
 _M_I86        |  -       1       -      -        1       1
 _M_I86SM      |  -       1       -      -        1       1
 _M_SDATA      |  -       1       -      -        1       1
 _M_STEXT      |  -       1       -      -        1       1
 _M_BITFIELDS  |  -       1       -      -        1       1
 _M_INTERNAT   |  -       1       -      -        1       1
 _M_SYS5       |  -       1       -      -        1       1
 _M_SYSV       |  -       1       -      -        1       1
 _M_SYS3       |  -       1       -      -        1       1
 _M_SYSIII     |  -       1       -      -        1       1
 _M_WORDSWAP   |  -       1       -      -        1       1
 i386          |  -       1       -      -        1       1
 unix          |  -       1       -      -        1       1
 M_I386        |  -       1       -      -        1       1
 M_UNIX        |  -       1       -      -        1       1
 M_XENIX       |  -       1       -      -        1       1
 _STRICT_NAMES |  1       -       1      1        1       -


-A name[(tokens)]
Assert name as a predicate associated with the optional parenthesized tokens as if by a #assert directive.

-A -
Unassert all preassertions. See also the option -R.

The affected preassertions are the following:

           #assert system(unix)
           #assert cpu(i386)
           #assert machine(i386)

-b format
Specify the file format of the produced object file. The file format of the produced binary is dictated by the runtime environment where the executable will be executed. This option is independent of the option -X dialect, which specifies a C language dialect, and independent of option -a api, which specifies a particular source-level API.

One of the following formats (case is not significant) can be specified:


coff
Produce COFF object files, which are also compatible with COFF files in older releases of SCO OpenServer operating systems. This is the default. The COFF version of ld, /usr/ccs/bin/coff/ld, is used directly to link object files if this option is explicitly specified. The default is to invoke /bin/ld to link object files.

ibcs2
Produce COFF object files, which are also iBCS2 compliant. This option implies the option -Knarrow_floats (see -K). Object files are linked using /bin/ld when this option is used.

elf
Produce an ELF (Executable and Linking Format) object file. The ELF version of ld, /usr/ccs/bin/elf/ld, is used to link object files.

When -b elf is specified, the following two options become the default: -Bdynamic and -dy.

This option is implied when any of the following options are also specified: -Bstyle, -dy or -dn, -G, -hname, and -zargs. Using any one of these options together with either -b coff or -b ibcs2 causes a compiler error.


CAUTION: Archive libraries given on the command line through -l option are not scanned for their file formats. If any of these libraries are in ELF format and cc uses COFF format, chosen either through the default option -b coff or through object file scanning, cc fails (because ld fails) and no executable will be produced. Always specify option -b elf if ELF and COFF files might be mixed. However, never mix ELF and COFF modules in the same archive library. Mixing ELF and COFF modules in the same archive library causes ld to fail. See ``Generating COFF vs. ELF binaries'' in ld(CP) for further details.

The following manifests are affected by the format argument:

    format    
Manifest coff elf ibcs2  
_IBCS2 - - 1  
_M_COFF 1 - 1  
_SCO_COFF 1 - 1  
_SCO_ELF - 1 -  

           |        format
 Manifest  | coff   elf      ibcs2
 _IBCS2    |  -       -        1
 _M_COFF   |  1       -        1
 _SCO_COFF |  1       -        1
 _SCO_ELF  |  -       1        -

-B style
Control the linking phase library name search mechanism for subsequent -l options. This option is passed to ld in the linking phase. The option argument style can be one of dynamic (the default setting), static, or symbolic, all in lower case. The order of the -B, -L, and -l options is significant in controlling which library is linked. See ld(CP) man page for further details.

This option implies -b elf and cannot be used with -b coff.


-c
Suppress the linking stage and do not create an executable file. Object files (.o files), if produced, are not removed.

-C
In the preprocessed source, retain all comments unless they are on the same lines as preprocessing directives. These preserved comments can be used by lint(CP) later. The default is to remove all comments when preprocessing a file.

-d letter
Govern dynamic linking. This option implies -b elf when -b elf is not used. letter can be either y or n:

y
Produce a dynamically linked executable. This is the default when -b elf is used.

n
Produce a statically linked executable.

-D name[=string]
Define name to be a macro and replace this macro by the value of string. If the optional =string part is not given, the macro is replaced by 1. The effect of using this option is the same as if name were defined through a #define directive in the source file following this option. See the -a and -b options for more information on the default manifest defines. The -D option can be used several times on the command line, but it must not define the same name twice.


NOTE: When building a multi-threaded application, you should specify -D_REENTRANT. This changes the behavior of some interfaces in certain headers; see errno in <errno.h> for an example.


-e name
Set the default entry point address for the output file to be the address of name.

-E
Suppress all phases but preprocessing, and send the result to the standard output. The result contains lines similar to preprocessing directives and can be used for a subsequent compiling phase.

-g
Include debugging information in the output file for symbolic debugging. If -O is also specified, -g takes precedence.

-G
Direct ld(CP) to produce a shared object in the ELF file format when it is linking a dynamically linked binary (-b elf -dy). No executable is produced. This option implies -b elf when -b elf is not used.

-h name
Direct ld to use name as the output filename in the object's dynamic section when building a shared object. See ld(CP) man page.

This option implies -b elf and cannot be used together with -b coff.


-H
Print the pathnames of all included files, one per line, on the standard error output.

-i, -ii, -iii
Turn on driver debugging. See options -#, -##, and -### for detailed descriptions.

-I directory
Search an include file in directory before searching the standard list of directories, if an absolute pathname is not used for the include file. If the -I option is used multiple times, these additional directories are first searched for include files in the order specified by -I.

-J
Make the data type char to be unsigned by default.

-K list
Fine tune the optimization and code generation. The option argument list is a comma-separated list of one or more of the items in the following list. Multiple -K options have the same effect as if the separate list arguments were merged into one option. For those items in the following list presented in groups of two or more, the first item is the default choice, and only one in each such group will be effective. Many items in such groups act as a binary switch: the forms without a leading no (for example ieee) enable the behavior and the forms with a leading no (for example no_ieee or noieee) turn off the behavior. Some of the items also have their abbreviated forms (for example, lu for loop_unroll). These abbreviated forms are enclosed within parentheses and listed next to their unabbreviated forms.

The following items (case is not important) can be used in the option argument list of option -K:


no_alloca
noalloca
alloca
Use the built-in alloca( ) function for occurrences of alloca( ) in the source code. This option must be used together with -O.

pic
Instruct the compiler to produce position independent code when used with -b elf.

blended
pentium
i486
i386
Optimize code generation specifically for the selected processor. blended balances the code generation choices to work well on all processors and is the default. To target a particular processor, use i386 for Intel's i386(TM) class of processors, use i486 for Intel's i486(TM) class of processors, and use pentium for Intel's more advanced Pentium(TM) class of processors.

ieee
no_ieee
noieee
Control whether the generated floating-point code strictly conforms to the IEEE floating-point and C standards. ieee specifies strict conformance. no_ieee or noieee 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.

frame
no_frame
noframe
Specify whether the generated code must use the %ebp register as the stack frame pointer. no_frame or noframe permits %ebp to be allocated as a general purpose register, which can cause debugging stack traces to be unreliable, but usually produces faster code. frame is the default, except for -O3.

This option must be used with -O.


host
no_host
nohost
In hosted mode (host), 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. In the non-hosted mode (no_host or nohost), if no_ieee is also specified, the compiler assumes that math functions do not have NaNs or infinities as arguments and that they do not produce NaNs or infinities.

no_inline
noinline
inline
Specify whether the compiler should perform inlining of functions defined in user source code. Inlining may yield better execution speed at the expense of extra code size. no_inline is the default, except for -O2, -O3.

This option must be used with -O.


no_loop_unroll (no_lu)
noloop_unroll (nolu)
loop_unroll (lu)
Specify whether the compiler performs loop unrolling when optimization (-O) is enabled. Loop unrolling may yield better execution speed at the expense of extra code size. no_lu is the default, except for -O2, -O3.

no_alt_struct_pack (no_asp)
noalt_struct_pack (noasp)
alt_struct_pack (asp)
Use an alternate structure packing. This is useful for generating iBCS2-compliant binaries.

no_alt_struct_return (no_asr)
noalt_struct_return (noasr)
alt_struct_return (asr)
Use an alternate structure return. This is useful for generating iBCS2-compliant binaries.

no_narrow_floats (no_nf)
nonarrow_floats (nonf)
narrow_floats (nf)
Pass prototyped floats as 4 bytes long. no_nf is the default, except with -b ibcs2.

no_rodata
norodata
rodata
Put const data and const strings into read-only memory. This option is turned off (no_rodata) by default, and is only supported for ELF binaries.

no_space
nospace
space
Do not sacrifice space in the optimizations. This option must be used with -O.

-l name
Search a library libname.a (and preferentially libname.so if any user-specified objects are in ELF format or if the option -b elf is used without -dn) for unresolved function references. By default, cc directs ld to search libcrypt, libgen, and libc, in that order, for any still unresolved function references.

-L directory
Add directory to the front of the library search path. This option is passed to ld(CP).

-o filename[.i|.o|.s]
Use filename as the name of the executable file instead of the default name. With the option -c, in other words, when the linking phase is suppressed, the generated object file can be renamed through the option -o filename.o; with option -S, the generated .s file can be renamed; with option -P, the generated .i file can be renamed.

-O [n]
Turn on optimization and, optionally, set the optimization level. Use option -K to fine-tune optimization. This option is incompatible with -g in that if -g is used, -O[n] is completely ignored.


CAUTION: If there is any ambiguity in the source code (for example, uninitialized variables, undefined order of evaluation, etc), the generated code may behave differently with any optimization.

The level n can be one of 0, 1 (the default), 2 and 3. The higher the level, the more aggressive the optimization.


0
Disable some more aggressive optimizations. With this option, the ordering of generated code corresponds more closely to the source. This is useful for debugging (however, -O0 still cannot be used with -g and is ignored if -g is used).

1
This is the default. Most optimizations are turned on at this optimization level.

2
Turn on some more aggressive optimization.

3
Turn on the full optimization.


NOTE: The optimization levels are closely related to the settings of various -K options. For example, specifying -O3 automatically turns on -Kno_frame. Setting n to a value other than 1 may change the default value of -K options, and changing the default value of -K options may also override the default behavior of optimization levels.


-p
Generate and store extra code into the executable program for program profiling. When the executable program is run, the profiling information is saved into the file mon.out, which can be examined later using prof(CP). This is equivalent to -qp.

-P
Preprocess only each source file. The result is placed in a .i-suffixed file. Unlike -E, the result will contain no #line directives. Compiling this resultant .i file produces an executable whose line numbers match the .i file instead of the .c file.

-q letter
Cause extra code that instruments the program to be generated. The option argument letter can be either l or p:

l
Enable the basic block profiling which generates extra code that counts the number of times each source line is executed. The output from the profiling can be examined with lprof(CP).

p
This is equivalent to -p.


NOTE: If both -ql and -O options are specified, the -O option is ignored.


-Q letter
Control the inclusion of compilation tool identification information in the output. If letter is y (the default), the information will be present; if letter is n, it will not.


NOTE: Unless option -b elf is specified (explicitly or implicitly), as(CP) and ld(CP) do not support version stamping when invoked by cc.


-R
Remove all manifest defines set by the driver. Note that this does not include manifests specified by the ANSI C standard and defined by the compiler, such as __DATE__, __LINE__. See options -a and -b for the list of manifests.

-s
Strip symbolic information from the output file. The debug and line sections and their associated relocation entries will be removed. Except for relocatable files or shared objects, the symbol table and string table sections will also be removed from the output object file. This option is passed to ld.

-S
Create an assembly source listing and save it in a .s-suffixed file.

-u symbol
Designate the specified symbol as an undefined symbol in the symbol table. This option is passed to ld(CP).

-U definition
Undefine definition as if by a #undef directive, even if definition is a predefined macro (including those manifests that begin with __) or is also the subject of a -D option. This option is passed to the preprocessor.

-v
Perform extra syntactic, semantic, and lint(CP)-like checks during the compiling phase. This is equivalent to -w 3.

-V
Direct the cc command and each invoked tool to print its version information, one per line, on the standard error output.

-w level
Set the compiler warning message level. level is a digit 0 through 3, letter x or X. This option does not affect the text of compiler error messages.

0
Do not issue any warning messages.

1
Issue most warning messages (the default level).

2
Issue even more warning messages, including some warnings about behavioral changes from K&R C (see -Xk) to ANSI C.

3
Issue all of the above warning messages, and more. Use -w2 or -w3 when initially porting K&R code to an ANSI environment. See ``C compiler diagnostics'' in the Programming Tools Guide for more details.

x, X
Cause all compiler warnings to be fatal. This can be combined with -w0, -w1, -w2, or -w3.


-W tool,list
Pass the comma-separated list of arguments list (in order) to the single compilation pass named by tool. To include a comma in an argument in list, precede the comma by a \ character, for example,

cc -W a,-b elf, -Y d\,., -m ... file ...

which passes -b elf -Y d,. -m to as. If more than one conceptual pass is implemented by a single tool, all the associated argument lists are passed to the tool. The option argument tool is one or more of the following:


p
preprocessor

0
compiler

2
optimizer

b
block profiler

a
assembler

l
linker

Relative to the regular options and arguments passed to the compilation pass, the location of the arguments specified by list is unspecified and may change.


-X dialect
Control the degree of conformance to the ANSI and ISO C standards in the C language itself, or select a pre-ANSI C dialect. See ``C language compiler'' and ``ANSI implementation-defined behavior'' in the Programming Tools Guide for details on the C language being implemented and the implementation-defined behavior and extensions. This option is independent of the source-level API used in compiling the source file (specified through option -a), although some standards (for example, ANSI C) specify the C language and an API at the same time. This option is also independent of the object file format intended for the run-time environment (specified through option -b).

The option argument dialect can be one of the following:


a
Extended ANSI C (the default option). Specifies ANSI and ISO C 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 language constructions behave as specified in the standards. All implemented language extensions beyond the standards are also available.

c
Conformant ANSI and ISO C. This is a strict standards conforming C compiler satisfying the language specification in all respects, including issuing all necessary diagnostics for illegal programs. Certain extensions (such as the asm keyword) are not available in this dialect.

k
The ``classic'' C, or the dialect compatible with K&R C (see Kernighan & Ritchie, First Edition).

m
A Microsoft C compiler compatibility mode. This is equivalent to option -Xa, plus some (but not all) language extensions provided in the older C compiler, that were derived from Microsoft C compiler version 6. In particular, some Intel-specific keywords like near and far are supported. Use mcc(CP) if you need the compiler to understand most of the options accepted by older releases of the SCO OpenServer C compiler.


CAUTION: Use of this option (-Xm) is discouraged; it is intended only as a transitional aid and may not be supported in future releases.


t
A ``transitional mode'' between K&R and ANSI C. This specifies ANSI and ISO C standards conformance except where the semantics differ from ``classic'' C. 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 warns about expressions in which the modified promotion rules for narrower unsigned values may cause an otherwise hidden behavior change, if the warning level is 2 or higher.


-Y pass,dir
Find the item(s) named by pass in the directory dir. The option argument pass is one or more of the following:

p
preprocessor

0
compiler

2
optimizer

b
basic block profiler

a
assembler

l
linker

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. In addition, any one of the following can also be used as the option argument pass:


I
Change the directory searched last for preprocessing phase include files.

L
Change the linking phase default library search path to dir.

P
Change 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. This option is incompatible with -YU and -YL when linking ELF binaries and will cause an error if it is used with either one of them.

S
Change the directory in which to find the start-up object files (crt files).

U
Change the linking phase library search path LIBDIR to dir.

In addition to the ability to specify the directory in which to find the various compilation passes, if the cc command is renamed and 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 ./ALTcc is invoked with -Ya,../xyz, then the assembler would be expected to have the pathname ../xyz/ALTas.


NOTE: The position of -Y[ULP] is significant and may affect the operation of ld(CP).


-z arg
Turn on asserts of arg in the linker. This option must be used with option -b elf. The option argument arg can be one of defs, nodefs, and text. See ld(CP) man page. This option implies -b elf.

-Z packarg
Control the default packing of structures in the compiling phase. The option argument packarg is one of the following:

p, p1
Select at least one-byte alignment for all structure members; or, in other words, include no padding.

p2
Select at least two-byte alignment for structure members of at least two bytes in size.

p4
Select two-byte alignment for two-byte sized structure members and four-byte alignment for larger structure members. This is the default.

The cc command accepts (and may choose to ignore) some obsolete and unnecessary options including -f, which at one time requested floating point support. 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. If a mode choice option (such as -Q or -X) is specified more than once, generally the last one is used.

New code should use -Xa -Khost (the default); K&R code is probably best handled with -Xt (or -Xk) and -Kno_host.

For a typical multiuser i486 microprocessor-based system, the fastest code will probably be generated by using the -Xa, -Kno_ieee, and -O3 options, and by using the standard include files such as <string.h>. However, if the system has lots of memory, or if a single run of the program is critical, and binary portability is not a concern, the -dn option should also be used when the ELF format is requested.

Default options

By default, cc uses a set of default options when no option is given to it. This set of default options may be overridden through the FLAGS= lines in the file /etc/default/cc.

cc 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.


NOTE: 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.

An example /etc/default/cc file follows:

   FLAGS= -b elf

LIBS= -lm
This invokes the ELF version of compiler passes and includes libm.a on all links.

Environment variables

cc supports three environment variables: CCFLAGS, CCLIBS, and TMPDIR:


CCFLAGS
CCFLAGS 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.

TMPDIR
The TMPDIR variable can be used to specify the pathname of a directory where cc places temporary files during its compiling and linking processes.

Exit values

Upon successful completion, the exit status of cc is 0, otherwise the exit status is non-zero.

Examples

More flexibility is built into this C compiler, and, through option combinations, multiple standards are supported.

For example, to request the complete and strict ANSI C environment, you can use the option combination -Xc -a ansi. With this option combination, none of the SCO OpenServer extensions to the ANSI C language and the API defined with the ANSI C language are available. All necessary diagnostics for illegal programs will be issued. If you need to emulate as close as possible the default environment provided by older releases of the SCO OpenServer Development System, use the option combination -Xm -a ods30 -b coff. The following table gives a list of frequently used option combinations and the corresponding environments that the compilation system provides.

Option combination Environment
-Xc -a ansi strict ANSI C
-Xa -b ibcs2 -D_SVID strict iBCS2 runtime
-Xc -a posix strict POSIX
-Xc -a xpg4 strict XPG4
-Xm -a ods30 -b coff SCO Open Desktop Development System Release 3.0
-Xk -Kno_host ``classic'' K&R C

 +---------------------+-------------------------------------------------+
 |Option combination   | Environment                                     |
 +---------------------+-------------------------------------------------+
 |-Xc -a ansi          | strict ANSI C                                   |
 +---------------------+-------------------------------------------------+
 |-Xa -b ibcs2 -D_SVID | strict iBCS2 runtime                            |
 +---------------------+-------------------------------------------------+
 |-Xc -a posix         | strict POSIX                                    |
 +---------------------+-------------------------------------------------+
 |-Xc -a xpg4          | strict XPG4                                     |
 +---------------------+-------------------------------------------------+
 |-Xm -a ods30 -b coff | SCO Open Desktop Development System Release 3.0 |
 +---------------------+-------------------------------------------------+
 |-Xk -Kno_host        | ``classic'' K&R C                               |
 +---------------------+-------------------------------------------------+

Files


/bin/cc
a link to /usr/ccs/bin/ucc

/usr/ccs/bin/cc
a link to /usr/ccs/bin/ucc

/usr/ccs/bin/ucc
the ``real'' C driver


./a.out
default filename of the resulting executable

INCDIR
last directory to search for include files, usually /usr/include

LIBDIR
usually /usr/ccs/lib

BINDIR
usually /usr/ccs/bin

LIBPATH
usually /usr/ccs/lib:/lib:/usr/lib

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

TMPDIR
usually /tmp but can be overridden by the environment variable TMPDIR.

/usr/lib/nls/msg/locale/unixds
language-specific message file (See LANG in localedef(F)).

See also

ar(CP), as(CP), ld(CP), lint(CP), localedef(F), lprof(CP), mcc(CP), monitor(S), nm(CP), prof(CP), strip(CP), tmpnam(S)

``C language compiler'' and
``ANSI implementation-defined behavior'' in the Programming Tools Guide

The UDK and GNU C compilers are also provided for SCO OpenServer. Beginning with Release 5.0.7, these alternate development systems are included on the SCO OpenServer media. For earlier releases, the UDK tools for SCO OpenServer are available on the UDK media with the OSRcompat Binary Compatibility Module (also available for download from http://www.sco.com/download) and the GNU tools for SCO OpenServer are available on the Skunkware media as well as http://www.sco.com/skunkware.

Standards conformance

cc is conformant with:

X/Open Portability Guide, Issue 3, 1989 .


© 2003 Commands for Programming (CP)
SCO OpenServer Release 5.0.7 -- 11 February 2003