CC(1) — USER COMMANDS
NAME
cc − C compiler
SYNOPSIS
cc [ −c ] [ −g ] [ −o output ] [ −O ] [ −a ] [ −Aasmflags ] [ −C ] [ −Dname ] [ −Dname=def ] [ −E ]
[ −fsingle ] [ float_option ] [ −go ] [ −Idir ] [ −p ] [ −pg ] [ −R ] [ −S ]
[ −t[p|0|2|a|c|l]] [ −Bstring ] [ −Uname ] [ −v ] [ −w ] filename ...
DESCRIPTION
Cc is the UNIX C compiler which translates programs written in the C programming language into executable load modules, or into relocatable binary programs for subsequent loading with the ld(1) linker.
In addition to the many options, cc accepts several types of files. Files whose names end with .c are taken to be C source programs; they are compiled, and each resulting object program is left in the current directory, with the same name as the source file, except that the .c suffix is replaced by .o. In the same way, files whose names end with .s are taken to be assembly source programs and are assembled, producing a .o file.
Other arguments are taken to be loader option arguments, object programs, or libraries of object programs. Unless −c, −S, or −E is specified, these programs and libraries, together with the results of any compilations or assemblies specified, are loaded (in the order given) to produce an executable program named a.out. The name a.out can be overridden with the loader’s −o option.
If a single C program is compiled and loaded all at once, the intermediate .o file is deleted.
OPTIONS
The following options are interpreted by cc. See ld(1) for load-time options.
−c Compile only — suppress the loading phase, and force an object file to be produced even if only one program is compiled.
−g Produce additional symbol table information for dbx(1) and pass the −lg flag to ld(1).
−o output
Name the final output file output. If this option is used, the file a.out is left undisturbed.
−O Invoke the object code optimizer to improve the generated code. This option should be used for all production code, though not during development, since it slows the compiler down.
−a Insert code into the program to count how many times each basic block in the program is executed. This process is performed after the C preprocessor cpp has run but before compilation takes place. After the program is compiled with this option, there will be a .d file for every .c file. 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. The −a option must be used when linking with the cc(1) or ld(1) command also.
−Aasmflags
Pass asmflags to the assembler as in its command line. For example, −A−j would pass the −j option to tell the assembler to use short PC-relative instructions for subroutine calls.
−C Prevent the C preprocessor from removing comments.
−Dname
−Dname=def
Define name to the preprocessor, as if by ‘#define’. If no definition is given, the name is defined as "1".
−E Run only the C preprocessor on the named C programs, and send the result to the standard output.
−fsingle
Use single-precision arithmetic in computations involving only float numbers — that is, do not convert everything to double, which is the default. Note that floating-point parameters are still converted to double precision, and functions which return values still return double precision values. Certain programs run much faster using this option, but be aware that some significance can be lost due to lower precision intermediate values.
float_option
Floating point code generation option. Can be one of:
−fsoft software floating-point calls (this is the default).
−fsky in-line code for Sky floating-point processor (supported only on Sun-2).
−f68881 in-line code for Motorola MC68881 floating-point processor (supported only on Sun-3).
−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 options.
When invoked without float_option, the compiler interrogates the FLOAT_OPTION environment variable to determine the type of floating-point code to generate. Legal values for FLOAT_OPTION are: ‘fsoft’, ‘fsky’, ‘f68881’, ‘ffpa’ and ‘fswitch’.
−go Produce additional symbol table information in an older format used by the adb debugger and pass the −lg flag to ld(1).
−Idir ‘#include’ files whose names do not begin with ‘/’ are always sought first in the directory of the file argument, then in directories named in −I options, then in the /usr/include directory.
−p Produce profiling code to count the number of times each routine is called. If loading takes place, replace the standard startup routine by one that automatically calls monitor(3) and use a special profiling library in lieu of the standard C library. When the program is run, the file mon.out is created. An execution profile can then be generated by use of prof.
−pg Produce profiling code in the manner of −p, but invoke a run-time recording mechanism that keeps more extensive statistics and produces a gmon.out file at normal termination. gprof(1) generates an execution profile.
−R Passed on to as(1), making initialized variables shared and read-only.
−S Compile the named C programs and leave the assembly language output on corresponding files suffixed .s.
−t[p012acl]
Use the designated compiler components in the directory named in the −B option. In the absence of a −B option, the directory is taken to be /usr/new. The combinations that can be specified for the −t option are:
pcpp — the C preprocessor.
0ccom — the C compiler proper.
2c2 — the assembly code optimizer.
aas — the assembler.
clibc — the C library.
lld — the loader.
−Bstring Find substitute compiler components in the directory string, which must be a pathname terminated with a slash (/).
−Uname Remove any initial definition of name for the C preprocessor.
−v Display a message on standard error indicating the argument string that invoked each phase of the compiler.
−w Suppress warning messages.
FILES
file.cC source file
file.sassembler source file
file.oobject file
file.alibrary of object files
a.outexecutable output file
/tmp/ctm?compiler temporary file
/lib/Fcrt1.ostartup code for −fsoft option
/lib/Mcrt1.ostartup code for −f68881 option
/lib/Scrt1.ostartup code for −fsky option
/lib/cppmacro preprocessor
/usr/lib/bb_countblock counting preprocessor
/lib/ccomcompiler
/lib/c2optional optimizer
/lib/crt0.oruntime startoff
/lib/mcrt0.ostartoff for profiling
/usr/lib/gcrt0.ostartoff for gprof-profiling
/usr/lib/bb_link.obasic block counting routine
/lib/fcrt0.oSKY runtime startoff
/lib/fmcrt0.oSKY startoff for profiling
/usr/lib/fgcrt0.oSKY startoff for gprof-profiling
/lib/libc.astandard library, see intro(3)
/usr/lib/libc_p.aprofiling library, see intro(3)
/usr/includestandard directory for ‘#include’ files
mon.outfile produced for analysis by prof(1)
gmon.outfile produced for analysis by gprof(1)
/usr/newdefault directory for components listed in the −t option
SEE ALSO
B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, 1978
UNIX Programming in Programming Tools for the Sun Workstation
monitor(3), prof(1), gprof(1), tcov(1), adb(1), ar(1), ld(1), dbx(1), as(1), diff(1), cpp(1)
DIAGNOSTICS
The diagnostics produced by C itself are intended to be self-explanatory. Occasional obscure messages may be produced by the preprocessor, assembler, or loader.
BUGS
Options that are identical to cc options cannot be passed to the assembler, optimizer or loader.
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.
Sun Release 3.0β — Last change: 21 December 1985