Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cc(1) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

adb(1)

cdb(1)

cpp(1)

as(1)

ld(1)

prof(1)

exit(2)

monitor(3C)

matherr(3M)

CC(1)  —  HP-UX

NAME

cc − C compiler

SYNOPSIS

cc [ options ] files

DESCRIPTION

Cc is the HP-UX C compiler.  It accepts several types of arguments:

(1) 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.  However, if a single C program is compiled and linked all in one step, the .o file is deleted. 

(2) Similarly, arguments whose names end with .s are taken to be assembly source programs and are assembled, producing a .o file. 

(3) Arguments whose names end with .o are taken to be relocatable object files that 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

Options

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 for each .c file even if only one program is compiled.  Object files produced from C programs must be linked before being executed. 

−C Prevent the preprocessor from stripping C-style comments.  See cpp(1) for details. 

−Dname=def

−Dname Define name to the preprocessor, as if by ’#define’.  See cpp(1) for details. 

−E Run only cpp(1) on the named C or assembly programs, and send the result to the standard output. 

−g Cause the compiler to generate additional information needed by the symbolic debugger. 

−Idir Change the algorithm used by the preprocessor for finding include files to also search in directory dir.  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 the 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 assembly 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, which produces a step-by-step description of the compilation process on stderr.  Also echoes CCOPTS if it is set. 

−w Suppress warning messages. 

−W c,arg1[,arg2...]
Hand off the argument[s] argi to pass c where c can assume one of the values listed under the -t option as well as d (driver program).  The −W option specification allows additional, implementation-specific options to be recognized by the compiler driver.  For example, on the Series 300, −W d,−x causes the driver to call various subprocesses needed to generate MC68020 code. Furthermore, a shorthand notation for this mechanism can be used by placing "+" in front of the option name as in +x which is equivalent to the previous option example. Some commonly used subprocess options can also be abbreviated in a similar fashion. Note that for simplicity, this shorthand must be applied to each option individually.  Options that can be abbreviated using "+" are implementation-dependent, and are listed under HARDWARE DEPENDENCIES. 

−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 below. 

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 Kernighan 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. 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 an int. Additionally, either an int or a long can hold a pointer. 

HARDWARE DEPENDENCIES

Series 200, 300:
The following options are not supported:  −w  −z. 

The default is to allow null pointer dereferencing, hence using −Z has no effect. 

The default is to generate code for the processor on the machine where the compilation is taking place.  For example, on a Series 300 with a MC68020 processor, the compiler will generate MC68020 code. 

The compiler driver supports the following cross-compilation options, which may also be passed to it from cc using the -W d option. 

+x or −W d,−x
causes the compiler to generate inline code for the MC68020 and MC68881.

+X or −W d,−X
causes the compiler to generate "generic" MC68010 code. The code will also run on MC68020 processors, but it will not take advantage of new architectural capabilities.

The compiler subprocess ccom supports the following options, which may be passed to it from cc using the -W c option.  Some of these can be passed directly to the driver using the "+" notation. 

+b or −W c,−b
causes the MC68010 compiler to generate code for floating point operations that will use the 98635 floating point card if it is installed in the computer at run-time (if not installed, operations will be done in software). This option cannot be used when code is being generated explicitly for the MC68020, either by default on a MC68020 based system or via the +x option. 

+f or −W c,−f
causes the MC68010 compiler to generate code for floating point operations that must use the 98635 floating point card.  This code does not run unless the floating point card is installed. This option cannot be used when code is being generated explicitly for the MC68020, either by default on a MC68020 based system or via the +x option. 

+M or −W c,−M
causes the MC68020 compiler NOT to generate inline code for the MC68881 math coprocessor.  Library routines will be referenced for matherr capability.  This option is meaningless on MC68010 based systems or in conjunction with +X. 

+N<secondary><n> or −W c,−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 is 10000 table entries. 

b maximum size of the bc table.  This table saves break and continue labels within loops and switch statements.  Default is 100 table entries. 

d maximum size of the dimtab table.  This table maintains information about the definitions of all structures, unions, and arrays.  Default is 1000 table entries. 

e maximum number of nodes per statement.  Default is 350 table entries. 

p maximum size of the parameter stack.  Default is 150 table entries. 

s maximum size of the symbol table.  Default is 1000 table entries. 

t maximum size of the tasciz table.  Default is 20000 table entries. 

w maximum size of the switch table stack.  Default is 250 table entries. 

−W c,−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. 

The following option is supported:

−Y Enable support of 16-bit characters inside string literals and comments. Note that 8-bit parsing is always supported.  See hpnls(5) for more details on International Support. 

Series 500:
The following options are not supported:  −p, −w. 

The default is not to allow null pointer dereferencing, hence using −z has no effect. 

The file /lib/mcrt0.o is not currently supported. 

The compiler subprocess ccom supports the following options, which may be passed to it from cc using the -W c option.  Some of these can be passed directly to the driver using the "+" notation. 

+N<secondary><n> or −W c,−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 {bpwgi}, 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:

b maximum size of the bc table.  This table saves break and continue labels within loops and switch statements.  Default is 100 table entries. 

p maximum size of the parameter stack.  Default is 150 table entries. 

g maximum size of the argument stack.  Default is 100 table entries. 

w maximum size of the switch table.  Default is 250 table entries. 

i maximum size of the instruction table for generated code.  Default is 300 table entries. 

The following option is supported:

−Y Enable support of 16-bit characters inside string literals and comments. Note that 8-bit parsing is always supported.  See hpnls(5) for more details on International Support. 

Series 800:

The default is to allow null pointer dereferencing, hence using −Z has no effect. 

The -g option is incompatible with optimization. 

The compiler subprocess ccom supports the following options, which may be passed to it from cc using the -W option.  Note:  The "+opt1 +opt2" notation may be used instead of the "-Wc,-opt1,-opt2" notation. 

+a or −W c,−a
When processing files which have been written in assembly language, do not assemble with the prefix file which sets up the space and subspace structure required by the linker. Files assembled with this option may not be linked unless they contain the equivalent information.

+Oopt or −W c,-Oopt
Invoke optimizations selected by opt.  If opt is ’1’, then only level 1 optimizations are handled.  If opt is ’2’, then all optimizations are performed.  The option +O2 is the same as −O. 

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 (for Series 200, Series 300 and Series 500 only)

/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
 

Series 200, 300:

/lib/ccom10 compiler, MC68010 version (linked to /lib/ccom on MC68010 systems). 

/lib/ccom20 compiler, MC68020 version (linked to lib/ccom on MC68020 systems). 

/lib/c210 optimizer, MC68010 version (linked to lib/c2 on MC68010 systems). 

/lib/c220 optimizer, MC68020 version (linked to lib/c2 on MC68020 systems). 

/bin/as10 assembler, MC68010 version (linked to /bin/as on MC68010 systems). 

/bin/as20 assembler, MC68020 version (linked to /bin/as on MC68020 systems). 
 

Series 800:

/lib/libp/libc.a C library for profiled programs

/usr/lib/cc_msgs.cat compiler messages catalog

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. 

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.

SEE ALSO

adb(1), cdb(1), cpp(1), as(1), ld(1), prof(1), exit(2), monitor(3C), matherr(3M).  B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, 1978.

INTERNATIONAL SUPPORT

8- and 16-bit data only in strings and comments, 8-bit filenames. 
Series 800 does not support 16-bit data.

Hewlett-Packard Company  —  Version B.1,  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026