CC(1V) — USER COMMANDS
NAME
cc − C compiler
SYNOPSIS
cc [ −a ] [ −align _block ] [ −B binding ] [ −c ] [ −C ] [ −dryrun ] [ I−D name [ =definition ] ] [ −E ] [ float-option ] [ −fsingle ] [ −g ] [ −go ] [ −help ] [ −I directory-name ] [ −J ] [ −l library ] [ −L directory ] [ −M ] [ −misalign ] [ −o output-file ] [ −O[level ] ] [ −p ] [ −P ] [ −pg ] [ −pic ] [ −PIC ] [ −pipe ] [ −Qoption program option ] [ −Qpath directory-name ] [ −Qproduce source-type ] [ −R ] [ −S ] [ target-architecture ] [ −temp=directory ] [ −time ] [ −Uname ] [ −v ] [ −w ] source-file ...
SYSTEM V SYNOPSIS
/usr/5bin/cc arguments
Note: arguments to /usr/5bin/cc are identical to those listed above.
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 file name 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. File names ending in .il are taken to be in line 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 file name 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 loaded (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 C program stored in a single file is compiled and loaded all at once, the intermediate .o file is deleted.
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 (Available on Sun-2, Sun-3, and Sun-4 systems.) 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). Each .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.
−B binding
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.
−dryrun
Show but do not execute the commands constructed by the compilation driver.
−Dname[=definition]
Define a symbol name to the C preprocessor (cpp(1)). Equivalent to a #define directive in the source. If no definition 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.)
float-option
Floating-point code generation option. Can be one of:
−f68881 Generate in-line code for the Motorola MC68881 floating-point processor (supported only on Sun-3 systems).
−ffpa Generate in-line code for Sun Floating Point Accelerator (supported only on Sun-3 systems).
−fsky Generate in-line code for Sky floating-point processor (supported only on Sun-2 systems).
−fsoft Generate software floating-point calls. Supported only on Sun-2 and Sun-3 systems, for which it is the default.
−fswitch Run-time-switched floating-point calls. The compiled object code is linked at run-time to routines that support one of the above types of floating point code. This was the default in previous releases. Only for use with programs that are floating-point intensive, and must be portable to machines with various floating-point hardware options (supported only on Sun-2 and Sun-3 systems).
−fsingle(Sun-2, 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 single-precision intermediate values.
−g Produce additional symbol table information for dbx(1) and dbxtool(1) and pass the −lg flag to ld(1). 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.
−Idirectory-name
Add directory-name to the list of directories to be searched for #include files with relative file names (not beginning with slash, /). The preprocessor first searches for #include files in the directory containing source-file, 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-2 and Sun-3 systems).
−lx Link with the object library libx.a (for ld(1)).
−Ldirectory
Add directory to the list of directories containing object library routines (for linking using ld(1)).
−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).
−o output-file
Name the output file output-file. output-file must have the appropriate suffix for the type of file to be produced by the compilation (see FILES, below). output-file cannot be the same as source-file (the compiler will not overwrite the source file).
−O[level]
Optimize the object code. Ignored when either −g, −go, or −a is used. On Sun-2 and Sun-3 systems, −O with the level omitted is equivalent to −O1. On Sun-4 systems, it is equivalent to −O2. on Sun386i systems, all levels are the same as 1. level is one of:
1 Do post pass assembly-level optimization only.
2 Do global optimization prior to code generation, including loop optimizations, common subexpression elimination, copy propagation, and automatic register allocation. −O2 does not optimize references to or definitions of external or indirect variables.
3 Same as −O2, but optimize uses and definitions of external variables. −O3 does not trace the effects of pointer assignments. Neither −O3 nor −O4 should be used when compiling either device drivers, or programs that modify external variables from within signal handlers.
4 Same as −O3, but trace the effects of pointer assignments.
−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. When used on a Sun386i, it has the same effect as −PIC.
−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 compilation stages. Note: This option is very CPU intensive.
−Qoption program option
Pass option to program. option must be appropriate to program and may begin with a minus sign. option may also be a string of valid options enclosed in double quotes. program can be one of as(1), cpp(1), inline(1), or ld(1).
−Qpath directory-name
Insert directory-name into the compilation search path to use alternate versions of programs invoked during compilation. directory-name will also be searched first for certain relocatable object files that are implicitly referenced by the compiler driver (such files as ∗crt∗.o and bb_link.o ).
−Qproduce source-type
Produce source code of the type source-type. source-type 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), c2 (Sun-2, Sun-3, Sun-4 systems only), or optim (Sun386i systems only).
−R Merge the data segment with the 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.
target-architecture
Compile object files for the specified processor architecture. Unless used in conjunction with one of the Sun Cross-Compilers, correct programs can be generated only for the architecture of the host on which the compilation is performed. target-architecture can be one of:
−sun2 Produce object files for a Sun-2 system.
−sun3 Produce object files for a Sun-3 system.
−sun4 Produce object files for a Sun-4 system.
−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 Verbose. Print the version number of the compiler and the name of each program it executes.
−w Do not print warnings.
ENVIRONMENT
FLOAT_OPTION (Sun-2, Sun-3, and Sun-4 systems only.) When no floating-point option is specified, the compiler uses the value of this environment variable (if set). Recognized values are: f68881, ffpa, fsky, fswitch, and fsoft.
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-2, Sun-3, Sun-4 systems only)
file.i C source file after preprocessing with cpp(1)
file.il inline 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-2, Sun-3, Sun-4 systems only)
/lib/bb_link.o basic block counting routine
/lib/c2 object code optimizer (Sun-2, Sun-3, Sun-4 systems only)
/lib/ccom compiler
/lib/cg code generator used with /lib/iropt (Sun-2, Sun-3, Sun-4 systems only)
/lib/compile compiler command-line processing driver
/lib/cpp macro preprocessor
/lib/crt0.o run-time startup code
/lib/Fcrt1.o startup code for −fsoft option (Sun-2, Sun-3, Sun-4 systems only)
/lib/gcrt0.o startup for profiling with gprof(1)
/lib/inline in line expander of library calls
/lib/iropt intermediate representation optimizer (Sun-2, Sun-3, Sun-4 systems only)
/lib/libc.a standard library, see intro(3)
/lib/libc_p.a profiling library, see gprof(1) or prof(1)
/lib/libm.a math library
/lib/mcrt0.o startup for profiling with prof(1)
/lib/Mcrt1.o startup code for −f68881 option (for Sun-3 systems)
/lib/optim Sun386i code optimizer
/lib/Scrt1.o startup code for −fsky option (for Sun-2 systems)
/lib/Wcrt1.o startup code for −ffpa option (for Sun-3 systems)
/usr/include standard directory for #include files
/usr/5lib/libc.a System V standard compatibility library, see intro(3V)
/usr/5lib/libc_p.a System V profiling library, see gprof(1) or prof(1)
/tmp/∗ compiler temporary files
mon.out file produced for analysis by prof(1)
gmon.out file produced for analysis by gprof(1)
SEE ALSO
adb(1), ar(1V), as(1), cpp(1), dbx(1), dbxtool(1), gprof(1), inline(1), ld(1), lint(1V), make(1), prof(1), tcov(1), intro(3), intro(3V), monitor(3)
Floating Point Programmers 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.
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 symbolic constants may be misleading.
Compiling with optimization level 2 or greater may produce incorrect object code if a function is 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 Release 4.0 — Last change: 3 May 1989