CC(1)
NAME
cc - C compiler
SYNOPSIS
cc [ options ] files
HP-UX COMPATIBILITY
Level: HP-UX/DEVELOPMENT
Origin: HP
Native Language Support:
8−bit and 16−bit characters in strings and comments.
DESCRIPTION
Cc is the HP-UX C compiler. It accepts several types of arguments:
Arguments whose names end with .c are taken to be C source programs. They are compiled, and each object program is left on the file whose name is that of the source with .o substituted for .c. The .o file is normally deleted, however, if a single C program is compiled and linked all in one step.
In the same way, arguments whose names end with .s are taken to be assembly source programs and are assembled, producing a .o file.
Arguments whose names end with .o are taken to be relocatable object files which are to be included in the link operation.
Arguments can be passed to the compiler through the CCOPTS environment variable as well as on the command line. The compiler picks up the value of CCOPTS and places its contents before any arguments on the command line. For example (in sh(1) notation),
CCOPTS=-v
export CCOPTS
cc -g prog.c
is equivalent to
cc -v -g prog.c
The following options are recognized by cc.
−c Suppress the link edit phase of the compilation, and force an object (.o) file to be produced even if only one program is compiled. Produces a .o file for each .c file.
−C Do not strip C-style comments in the preprocessor. See cpp(1) for details.
−Dname=def
−Dname Define "name" to the preprocessor. See cpp(1) for details.
−E Run only cpp(1) on the named C programs and send the result to the standard output.
−g Cause the compiler to generate additional information needed for the use of a symbolic debugger.
−Idir Change the search algorithm used by the preprocessor for finding include files. See cpp(1) for details.
−lx Cause the linker to search the library libx.a . See ld(1) for details.
−n Cause the output file from the linker to be marked as shareable. For details and system defaults, see ld(1).
−N Cause the output file from the linker to be marked as unshareable. For details and system defaults, see ld(1).
−o outfile Name the output file from the linker outfile . The default name is a.out.
−O Invoke an assembly code optimizer.
−p Arrange for the compiler to produce code that counts the number of times each routine is called; also, if link editing takes place, replace the standard startoff routine by one that automatically calls monitor(3C) at the start and arranges to write out a mon.out file at normal termination of execution of the object program. An execution profile can then be generated by use of prof(1).
−P Run only cpp(1) on the named C programs and leave the result on corresponding files suffixed .i.
−q Cause the output file from the linker to be marked as demand loadable. For details and system defaults, see ld(1).
−Q Cause the output file from the linker to be marked as not demand loadable. For details and system defaults, see ld(1).
−s Cause the output of the linker to be stripped of symbol table information. The use of this option will prevent the use of a symbolic debugger on the resulting program. See ld(1) for more details.
−S Compile the named C programs, and leave the assembler-language output on corresponding files suffixed .s.
−t c,name substitute or insert subprocess c with name where c is one or more of a set of identifiers indicating the subprocess(es). This option works in two modes: 1) if c is a single identifier, name represents the full path name of the new subprocess; 2) if c is a set of identifiers, name represents a prefix to which the standard suffixes are concatenated to construct the full path names of the new subprocesses. c can take one or more of the values:
p preprocessor (standard suffix is cpp)
c compiler body (standard suffix is ccom)
0 same as c
a assembler (standard suffix is as)
2 optimizer (standard suffix is c2)
l linker (standard suffix is ld)
−Uname Remove any initial definition of "name" in the preprocessor. See cpp(1) for details.
−v Enable verbose mode, producing a step-by-step description of the compilation process on stderr.
−w Suppress warning messages.
−Wc,arg1[,arg2...]
Hand off the argument[s] argi to pass c where c can assume one of the values listed under the -t option.
−Y Enable support of 8-bit and 16-bit characters inside string literals and comments. See HPNLS(7) for more details on Native Language Support.
−z Do not bind anything to address zero. This option will allow runtime detection of null pointers. See the note on pointers below .
−Z Allow dereferencing of null pointers. See the note on pointers below.
Any other options encountered will generate a warning to stderr.
Other arguments are taken to be C-compatible object programs, typically produced by an earlier cc run, or perhaps libraries of C-compatible routines. These programs, together with the results of any compilations specified, are linked (in the order given) to produce an executable program with the name a.out.
The Kernighan and Ritchie C text, and the various addenda to it, comprise the best available reference on C. The documents are intentionally ambiguous in some areas. HP-UX specifies some of these.
char
The char type is treated as signed by default. It may be declared unsigned.
pointers
Accessing the object of a NULL (zero) pointer is technically illegal, (see Kerninghan and Ritchie) but many systems have permitted it in the past. The following is provided to maximize importability of code. If the hardware is able to return zero for reads of location zero (when accessing at least 8 and 16 bit quantities), it must do so unless the -z flag is present. The -z flag requests that SIGSEGV be generated if an access to location zero is attempted. Writes of location zero may be detected as errors even if reads are not. If the hardware cannot assure that location zero acts as if it was initialized to zero or is locked at zero, the hardware should act as if the -z flag is always set.
identifiers
Identifiers are significant up to 255 characters.
types
Certain programs require that a type be a specific number of bits wide. The header file model.h (see model(5)) contains a number of standard definitions for objects of a constant width, independent of the individual implementation. It can be assumed that an int can hold at least as much information as a short, and that a long can hold at least as much information as a an int. Additionally, either an int or a long can hold a pointer.
HARDWARE DEPENDENCIES
Series 200:
The following options are not supported: −w −z
The default is to allow null pointer dereferencing, hence using −Z has no effect.
The compiler subprocess ccom supports the following options which may be passed to it from cc using the -W option.
−b causes the compiler to generate code for floating point operations that will use floating point hardware if it is installed in the computer at run-time.
−f causes the compiler to generate code for floating point operations that will use floating point hardware. This code will not run unless floating point hardware is installed.
−N<secondary><n>
This option adjusts the size of internal compiler tables. The compiler uses fixed size arrays for certain internal tables. Secondary is one of the letters from the set {abdepstw}, and n is an integer value. Secondary and n are not optional. The table sizes can be re-specified using one of the secondary letters and the number n as follows:
a maximum size of the asciz table Default = 10000 table entries.
b maximum size of the bc table. This table saves break and continue labels within a switch statement. Default = 100 table entries.
d max size of the dimtab table. This table maintains information about the definitions of all structures, unions, and arrays. Default = 1000 table entries.
e max number of nodes per statement. Default = 350 table entries.
p max size of the parameter stack. Default = 150 table entries.
s max size of the symbol table. Default = 1000 table entries.
t max size of the tasciz table. Default = 20000 table entries.
w max size of the switch table stack. Default = 250 table entries.
−YE This option causes source code lines to be printed on the assembly (.s) file as assembly comments, thus showing the correspondence between C source and the resulting assembly code.
Series 500:
The following options are not supported: −p −w −Z
The default is not to allow null pointer dereferencing, hence using −z has no effect.
The file /lib/mcrt0.o is not currently supported.
EXAMPLE
The following will compile the C program prog.c, creating a prog.o file, and will then invoke the link editor ld(1) to link prog.o and procedure.o with all the C startup routines in /lib/crt0.o and library routines from the C library libc.a; the resulting executable program is output in prog:
cc prog.c procedure.o -o prog
FILES
file.c input file
file.o object file
a.out linked output
/tmp/ctm∗ temporary
/usr/tmp/ctm∗ temporary
/lib/cpp preprocessor
/lib/ccom compiler, cc
/lib/c2 optional optimizer
/bin/as assembler, as(1)
/bin/ld link editor, ld(1)
/lib/crt0.o runtime startoff
/lib/mcrt0.o startoff for profiling
/lib/libc.a standard C library, see section 3 of this manual
/usr/include standard directory for #include files
SEE ALSO
adb(1), cdb(1), cpp(1), as(1), ld(1), prof(1), exit(2), monitor(3C), model(5).
B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, 1978.
NOTES
By default, the return value from a C program is completely random. The only two guaranteed ways to return a specific value are to explicitly call exit(2) or to leave the function main() with a “return expression;” construct.
DIAGNOSTICS
The diagnostics produced by C itself are intended to be self-explanatory. Occasional messages may be produced by the assembler or the link editor.
WARNINGS
Options not recognized by cc are not passed on to the link editor. The option -W l,arg may be used to pass any such option to the link editor.
Hewlett-Packard — last mod. May 11, 2021