CC(1) — USER COMMANDS
NAME
cc − C compiler
SYNOPSIS
cc [ −a ] [ −align _block ] [ −Bbinding ] [ −c ] [ −C ] [ −cg87 ] [ −cg89 ] [ −dalign ] [ −dryrun ]
[ −Dname [=def ] ] [ −E ] [ −f float_option ] [ −fast ] [ −fnonstd ] [ −fsingle ] ] [ −g ] [ −go ]
[ −help ] [ −Ipathname ] [ −J ] [ −Ldirectory ] [ −libmil ] [ −M ] [ −misalign ] [ −native ] [ −nolibmil ]
[ −o outputfile ] [ −O[ level] ] [ −p ] [ −P ] [ −pg ] [ −pic ] [ −PIC ] [ −pipe ]
[ −Qdir or −qdir directory ] [ −Qoption or −qoption prog opt ] [ −Qpath or −qpath pathname ]
[ −Qproduce or −qproduce sourcetype ] [ −R ] [ −S ] [ −sb ] [ −temp=directory ]
[ −time ] [ −Uname ] [ −V ] [ −v ] [ −w ] sourcefile ... [ −llibrary ]
DESCRIPTION
cc is the C compiler. It translates programs written in the C programming language into executable load modules, or into relocatable binary programs for subsequent loading with the ld(1) link editor.
In addition to the many options, cc accepts several types of filename arguments. For instance, files with names ending in .c are taken to be C source programs. They are compiled, and each resulting object program is placed in the current directory. The object file is named after its source file — the suffix .o replacing .c in the name of the object. In the same way, files whose names end with .s are taken to be assembly source programs. They are assembled, and produce .o files. Filenames ending in .il are taken to be inline expansion code template files; these are used to expand calls to selected routines in-line when code optimization is enabled. See FILES, below, for a complete list of compiler-related filename suffixes.
Other arguments refer to assembler or loader options, object programs, or object libraries. Unless −c, −S, −E −P or −Qproduce is specified, these programs and libraries, together with the results of any specified compilations or assemblies, are linked (in the order given) to produce an output file named a.out. You can specify a name for the executable by using the −o option.
If a single file is compiled and linked all at once, the intermediate files are deleted.
Before you use the cc command, insert /usr/lang (or the name of the directory in which you have chosen to install the C compiler) at the beginning of your search path. This is usually done in the .cshrc file, in a line with set PATH = at the start.
Before you use the man command for cc man pages, insert /usr/lang (or the name of the directory in which you have chosen to install the C compiler) at the beginning of your man path. This is usually done in the .cshrc file, in a line with set MANPATH = at the start.
OPTIONS
When debugging or profiling objects are compiled using the −g or −pg options, respectively, the ld command for linking them should also contain the appropriate option.
See ld(1) for link-time options.
−a Insert code to count how many times each basic block is executed. Invokes a run-time recording mechanism that creates a .d file for every .c file (at normal termination). The .d file accumulates execution data for the corresponding source file. The tcov(1) utility can then be run on the source file to generate statistics about the program. Since this option entails some optimization, it is incompatible with −g.
−align Force the global uninitialized data symbol block to be page-aligned by increasing its size to a whole number of pages, and placing its first byte at the beginning of a page.
−Bbinding Specify whether bindings of libraries for linking are static or dynamic, indicating whether libraries are non-shared or shared, respectively.
−c Suppress linking with ld(1) and produce a .o file for each source file. A single object file can be named explicitly using the −o option.
−C Prevent the C preprocessor, cpp(1), from removing comments.
−cg87 Sun-4 only. Generate code for any Sun-4. It does not exploit features such as the fsqrts and fsqrtd instructions that are not implemented in hardware on all Sun-4 workstations.
−cg89 Sun-4 only. Generate code for any newer Sun-4 that has features like hardware fsqrts and fsqrtd instructions. Code compiled with −cg89 should not be executed on Sun-4/1xx and 4/2xx systems with Weitek 1164/5 floating-point hardware.
-cg87 and -cg89 are mutually exclusive. This consistency may be enforced at run time.
−dalign(Sun-4 systems only.)
Generate double load/store instructions whenever possible for improved performance. Assumes that all double typed data are double aligned, and should not be used when correct alignment is not assured.
−dryrun Show but do not execute the commands constructed by the compilation driver.
−Dname[=def]
Define a symbol name to the C preprocessor (cpp(1)). Equivalent to a #define directive in the source. If no def is given, name is defined as ‘1’.
−E Run the source file through cpp(1), the C preprocessor, only. Sends the output to the standard output, or to a file named with the −o option. Includes the cpp line numbering information. (See also, the −P option.)
−fast Select the optimum combination of compilation options for speed. This should provide close to the maximum performance for most realistic applications. It is a convenience option, and it chooses the fastest code generation option available on the compile-time hardware ( −cg8x on a Sun-4), the optimization level −O2, a set of inline expansion templates, the −fnonstd floating-point option, and on a Sun-4, the −dalign option. If you combine −fast with other options, the last specification applies. The code generation option, the optimization level and using inline template files can be overridden by subsequent switches. For example, although the optimization part of −fast is −O2 , the optimization part of −fast-O3 is −O3 . Do not use this option for programs that depend on IEEE standard exception handling; you can get different numerical results, premature program termination, or unexpected SIGFPE signals.
−fnonstd Cause non-standard initialization of floating-point arithmetic hardware. By default, IEEE 754 floating-point arithmetic is nonstop and underflows are gradual The −fnonstd option causes hardware traps to be enabled for floating-point overflow, division by zero, and invalid operation exceptions. These are converted into SIGFPE signals, and if the program has no SIGFPE handler, it will terminate with a memory dump. See ieee_handler(3m).
−ffloat_option
Floating-point code generation option. Can be one of:
−f68881 Sun-3 only. Generate in-line code for Motorola MC68881 floating-point processor.
−ffpa Sun-3 only. Generate code for Sun Floating Point Accelerator (FPA).
−ffpaplus Sun-3 only. Generate code for FPA+.
−fsoft Sun-3 only. Generate software floating-point calls. It is the default.
−fswitch Sun-3 only. Run-time-switched floating-point calls. The compiled object code is linked at runtime to routines that support one of the above types of floating- point code. Only for use with programs that are floating-point intensive, and must be portable to machines with various floating-point hardware options. Using −fswitch is discouraged. Instead use fpversion –foption . See fpversion (1).
−fsingle(Sun-3 and Sun-4 systems)
Use single-precision arithmetic in computations involving only float expressions. Do not convert everything to double, which is the default. Note: floating-point parameters are still converted to double precision, and functions returning values still return double-precision values.
Although not standard C, certain programs run much faster using this option. Be aware that some significance can be lost due to lower-precision intermediate values.
−fstore Insure that expressions allocated to extended precision registers are rounded to storage precision whenever an assignment occurs in the source code. Only has effect when −f68881 is specified (Sun-3 systems only).
−g Produce additional symbol table information for dbx(1) and dbxtool(1) and pass −lg option to ld(1) (so as to include the g library, that is: /usr/lib/libg.a). When this option is given, the −O and −R options are suppressed.
−go Produce additional symbol table information for adb(1). When this option is given, the −O and −R options are suppressed.
−help Display helpful information about cc.
−Ipathname Add pathname to the list of directories in which to search for #include files with relative filenames (not beginning with slash /). The preprocessor first searches for #include files in the directory containing sourcefile, then in directories named with −I options (if any), and finally, in /usr/include.
−J Generate 32-bit offsets in switch statement labels (supported only on Sun-3 systems).
−llibrary Link with object library library (for ld(1)). This option must follow the sourcefile arguments.
−Ldirectory Add directory to the list of directories containing object-library routines (for linking using ld(1).
−libmil Select the best inline templates for the floating-point option and SunOS release available on this system.
−M Run only the macro preprocessor on the named C programs, requesting that it generate makefile dependencies and send the result to the standard output (see make(1) for details about makefiles and dependencies).
−misalign Generate code to allow loading and storage of misaligned data (Sun-4 systems only).
−native This option directs the compiler to compile code targeted for the machine that is doing the compiling. For a Sun-4 that means or
−nolibmil Reset −fast so that it does not include inline templates. Use this after the −fast option:
cc –fast –nolibmil ...
−o outputfile Name the output file outputfile. outputfile must have the appropriate suffix for the type of file to be produced by the compilation (see FILES, below). outputfile cannot be the same as sourcefile (the compiler will not overwrite the source file).
−O[level] Optimize the object code. Ignored when either −g, −go, or −a is used. −O with the level omitted is equivalent to −O2. level is one of:
1 Do postpass assembly-level optimization only.
2 Do global optimization before code generation, including loop-invariant optimizations, local and global common subexpression elimination, copy propagation, algebraic simplification, constant propagagation, basic block merging, tail recursion elimination, induction variable elimination, and automatic register allocation.
−O2 does not optimize references to or definitions of external variables or pointers.
3 Same as −O2, but do loop unrolling and optimize uses and definitions of external variables. −O3 does not trace the effects of pointer assignments.
4 Same as −O3, but trace the effects of pointer assignments, gather aliasing information, do parameter propagation, and perform inlining.‘
Neither −O3 nor −O4 should be used when compiling either device drivers, or programs that modify external variables from within signal handlers. Also, levels −O3 and −O4 may increase the size of executables; when optimizing for size, use −O2. If the optimizer runs out of memory, it tries to recover by retrying the current procedure at a lower level of optimization and resumes subsequent procedures at the original level.
−p Prepare the object code to collect data for profiling with prof(1). Invokes a run-time recording mechanism that produces a mon.out file (at normal termination).
−P Run the source file through cpp(1), the C preprocessor, only. Puts the output in a file with a .i suffix. Does not include cpp-type line number information in the output.
−pg Prepare the object code to collect data for profiling with gprof(1). Invokes a run-time recording mechanism that produces a gmon.out file (at normal termination).
−pic Produce position-independent code. Each reference to a global datum is generated as a dereference of a pointer in the global offset table. Each function call is generated in pc-relative addressing mode through a procedure linkage table. The size of the global offset table is limited to 64K on MC68000-family processors, or to 8K on SPARC processors.
−PIC Like −pic, but allows the global offset table to span the range of 32-bit addresses in those rare cases where there are too many global data objects for −pic.
−pipe Use pipes, rather than intermediate files, between cpp(1) and ccom compilation stages. (Very cpu-intensive.)
−Qdir or −qdir directory
Look for compiler components in directory X .
−Qoption or −qoption prog opt
Pass the option opt to the program prog. The option must be appropriate to that program and may begin with a minus sign. prog can be one of: as, cpp, inline, or ld.
−Qpath or −qpath pathname
Insert directory pathname into the compilation search path. pathname will be searched for alternate compilation programs, such as cpp(1), and ld(1). This path will also be searched first for certain relocatable object files that are implicitly referenced by the compiler driver, for example ∗crt∗.o and bb_link.o.
−Qproduce or −qproduce sourcetype
Produce source code of the type sourcetype. sourcetype can be one of:
.c C source (from bb_count).
.i Preprocessed C source from cpp(1).
.o Object file from as(1).
.s Assembler source (from ccom, inline(1) or c2).
−R Merge data segment with text segment for as(1). Data initialized in the object file produced by this compilation is read-only, and (unless linked with ld −N) is shared between processes. Ignored when either −g or −go is used.
−S Do not assemble the program but produce an assembly source file.
−sb Generate extra symbol table information for the Sun Source Code Browser.
−temp=directory
Set directory for temporary files to be directory.
−time Report execution times for the various compilation passes.
−Uname Remove any initial definition of the cpp(1) symbol name. (Inverse of the −D option.)
−V Print the name and version ID of each pass as the compiler executes.
−v Verbose. Print the version number of the compiler and the name of each program it executes.
−w Do not print warnings.
ENVIRONMENT
PATH The cc command requires that you insert /usr/lang (or the name of the directory in which you have chosen to install the C compiler) at the beginning of your search path. This is usually done in the .cshrc file, in a line with set PATH = at the start.
MANPATH To use the man command for cc man pages, insert /usr/lang (or the name of the directory in which you have chosen to install the C compiler) at the beginning of your man path. This is usually done in the .cshrc file, in a line with set MANPATH = at the start.
NOTE If you must use LD_LIBRARY_PATH , be sure to put the path /usr/lang/SC1.0 (or the name of the directory in which you have chosen to install the C compiler) at the start of that path list. It is safer to avoid this environment variable if you can.
FILES
a.out executable output file
file.a library of object files
file.c C source file
file.d tcov(1) test coverage input file (Sun-3, Sun-4 systems only)
file.i C source file after preprocessing with cpp(1)
file.il inline(1) expansion file
file.o object file
file.s assembler source file
file.S assembler source for cpp(1)
file.tcov output from tcov(1) (Sun-3, Sun-4 systems only)
/usr/lang/SC1.0/as assembler
/usr/lang/SC1.0/bb_link.o basic block counting routine
/usr/lang/SC1.0/cc compiler command-line driver
/usr/lang/SC1.0/ccom compiler
/usr/lang/SC1.0/cg code generator
/usr/lang/SC1.0/cpp macro processor
/usr/lang/SC1.0/crt0.o runtime startup code
/usr/lang/SC1.0/dbx symbolic debugger
/usr/lang/SC1.0/gcrt0.o startup for profiling with gprof(1)
/usr/lang/SC1.0/iropt global optimizer
/usr/lang/SC1.0/inline program that accomplishes inlining for libm.il
/usr/lang/SC1.0/libm.a math library
/usr/lang/SC1.0/libm.il math in-line library
/usr/lang/SC1.0/libm_p.a profiling library
/usr/lang/SC1.0/mcrt0.o start-up for profiling with prof(1) and intro(3)
/usr/lang/SC1.0/misalign.il in-line template file that allows loading and storage of misaligned data (Sun-4 only)
/usr/lang/SC1.0/sbrowser SunView interface to SourceBrowser
/usr/lang/SC1.0/sbquery command line interface to SourceBrowser
/usr/lang/SC1.0/sun_source_browser.ex
internal data file used by sbrowser and sbquery
/usr/lang/SC1.0/version gives version name
/usr/lang/SC1.0/_crt1.o initializes FPU in standard IEEE mode; C runtime object file
/usr/lang/SC1.0/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file
/usr/lang/SC1.0/cg87/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-4 only)
/usr/lang/SC1.0/cg87/nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-4 only)
/usr/lang/SC1.0/cg87/libm.a math library (Sun-4 only)
/usr/lang/SC1.0/cg87/libm.il math library inline (Sun-4 only)
/usr/lang/SC1.0/cg87/libm_p.il
inline template for profiling math library
/usr/lang/SC1.0/cg89/crt1.o initializes FPU in standard IEEE mode; C runtime object file (Sun-4 only)
/usr/lang/SC1.0/cg89/nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-4 only)
/usr/lang/SC1.0/cg89/libm.a math library (Sun-4 only)
/usr/lang/SC1.0/cg89/libm.il math library inline templates(Sun-4 only)
/usr/lang/SC1.0/cg89/libm_p.il
inline template for profiling math library
/usr/lang/SC1.0/misalign/crt0.o
runtime initialization (Sun-4 only)
/usr/lang/SC1.0/misalign/grt0.o
runtime initialization, non-standard (Sun-4 only)
/usr/lang/SC1.0/misalign/mrt0.o
runtime initialization, non-standard (Sun-4 only)
/usr/lang/SC1.0/c2 optional peephole optimizer (Sun-4/Sun-3)
/usr/lang/SC1.0/f68881/libm.a
MC68881 math library (Sun-3 only)
/usr/lang/SC1.0/f68881/libm.il
MC68881 math in-line library (Sun-3 only)
/usr/lang/SC1.0/f68881/libm_p.a
MC68881 profiling library (Sun-3 only)
/usr/lang/SC1.0/f68881/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/f68881/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/ffpa/libm.a FPA math library (Sun-3 only)
/usr/lang/SC1.0/ffpa/libm.il FPA math in-line library (Sun-3 only)
/usr/lang/SC1.0/ffpa/libm_p.a
FPA profiling library (Sun-3 only)
/usr/lang/SC1.0/ffpa/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/ffpa/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/ffpaplus/libm.a
FPA+ math library (Sun-3 only)
/usr/lang/SC1.0/ffpaplus/libm.i
FPA+ in-line library (Sun-3 only)
/usr/lang/SC1.0/ffpaplus/libm_p.a
FPA+ profiling library (Sun-3 only)
/usr/lang/SC1.0/ffpaplus/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/ffpaplus/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/fsoft/libm.a software floating-point math library (Sun-3 only)
/usr/lang/SC1.0/fsoft/libm.il software floating-point math in-line (Sun-3 only)
/usr/lang/SC1.0/fsoft/libm_p.a
software floating-point profiling library (Sun-3 only)
/usr/lang/SC1.0/fsoft/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/fsoft/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/fswitch/libm.a
runtime switched floating-point math library (Sun-3 only)
/usr/lang/SC1.0/fswitch/libm.il
runtime switched math in-line (Sun-3 only)
/usr/lang/SC1.0/fswitch/libm_p.a
runtime switched profiling library (Sun-3 only)
/usr/lang/SC1.0/fswitch/_crt1.o
initializes FPU in standard IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/fswitch/_nonstd_crt1.o
initializes FPU in non-IEEE mode; C runtime object file (Sun-3 only)
/usr/lang/SC1.0/tmp/∗ compiler temporary files
/usr/lang/SC1.0/xpg2include directory for X/Open #include files
/usr/lang/SC1.0/xpg2lib/libxpg.a
X/Open XPG2 compatibility library
/usr/lang/SC1.0/xpg2lib/libxpg_p.a
Profiled version of X/Open XPG2 compatibility library
mon.out file produced for analysis by prof(1)
gmon.out file produced for analysis by gprof(1)
.sb subdirectory that holds the information generated by the −sb option
SEE ALSO
adb(1), ar(1V), as(1), cflow(1V), cpp(1), ctags(1), cxref(1V), dbx(1), dbxtool(1), gprof(1), inline(1), ld(1), lint(1V), m4(1V), make(1), prof(1), tcov(1), intro(3), monitor(3)
Numerical Computation Guide
Programming Utilities and Libraries
B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, 1978
DIAGNOSTICS
The diagnostics produced by the C compiler are intended to be self-explanatory. Occasional obscure messages may be produced by the preprocessor, assembler, or loader.
NOTES
While the compiler allows 8-bit strings and comments, 8-bits are not allowed anywhere else. The cc command does not generate or support 8-bit symbol names because, until ANSI C, non-ASCII (7 bit) support was not expected. The ANSI C specification now suggests that string literals and comments can contain any characters from any character code set.
The following commands are affected by this lack of support for 8-bit characters: cflow(1V), cpp(1), ctags(1), cxref(1V), dbx(1), lint(1V), m4(1V), and yacc(1).
BUGS
The program context given in syntax error messages is taken from the input text after the C preprocessor has performed substitutions. Therefore, error messages involving syntax errors in or near macro references or manifest constants may be misleading.
Compiling with optimization level 2 or greater may produce incorrect object code if tail-recursion elimination is applied to functions called with fewer actual parameters (arguments) than the number of formal parameters in the function’s definition. Such parameter-count mismatches can be detected using lint(1V).
Sun C 1.1 — Last change: 22 January 1991