Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cc(1) — HP-UX 6.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

adb(1)

as(1)

cdb(1)

cpp(1)

gprof(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 understood to be C source files.  Each is compiled and the resulting object file is left in a file having the corresponding name, but suffixed with .o instead of .c.  However, if a single C file is compiled and linked all in one step, the .o file is deleted. 

(2) Similarly, arguments whose names end with .s are understood to be assembly source files and are assembled, producing a .o file for each .s file. 

(3) Arguments whose names end with .i are taken to be the output of cpp(1). (See the −P option below.)  They are compiled without again invoking cpp(1). Each object file is left in a file having the corresponding name, but suffixed .o instead of .i. 

(4) 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

When set, the TMPDIR environment variable specifies a directory to be used for temporary files, overriding the default directories /tmp and /usr/tmp. 

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 files, and send the result to the standard output. 

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

−G Prepare object files for profiling with gprof (see gprof(1)). 

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

-L dir Change the algorithm used by the linker to search for libx.a.  The −L option causes cc to search in dir before searching in the default locations.  This option is effective only if it precedes the −l option on the command line.  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 files and leave the result on corresponding files suffixed .i.  The −P option is also passed along to cpp(1).

−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 files, and leave the assembly language output on corresponding files suffixed .s. 

−t x,name Substitute or insert subprocess x with name where x is one or more of a set of identifiers indicating the subprocess(es).  This option works in two modes:  1) if x is a single identifier, name represents the full path name of the new subprocess; 2) if x 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.  x 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 the standard error.  Also echoes CCOPTS if it is set. 

−w Suppress warning messages. 

−W x,arg1[,arg2...]
Hand off the argument[s] argi to pass x, where x 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 DEPENDENCIES.

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

−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 standard error. 

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 portability 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. 

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. 

If any errors occur before cc is completed, a non-zero value is returned.  Otherwise, zero is returned. 

EXAMPLES

The following will compile the C file 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

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.

DEPENDENCIES

Series 300
The −z option is not supported. 

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 following options are also implementation specific:

+b Cause the MC68010 compiler to generate code that will use the 98635A floating point card, if it is installed at run-time.  If the card is not installed, floating point operations will be done in software.  This option is meaningless for the MC68020 compiler. 

+bfpa
Cause the MC68020 compiler to generate code that uses the 98248A floating point accelerator card, if it is installed at run-time. If the card is not installed, floating point operations are done on the MC68881 math coprocessor. This option is meaningless for the MC68010 compiler.

+f Cause the MC68010 compiler to generate code for the 98635A floating point card.  This code does not run unless the card is installed.  This option is meaningless for the MC68020 compiler. 

+ffpa Cause the MC68020 compiler to generate code for the 98248A floating point accelerator card.  This code does not run unless the card is installed.  This option is meaningless for the MC68010 compiler. 

+M Cause 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 for the MC68010 compiler. 

+N<secondary><n>
Adjust 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
Cause 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 800

The −L option and the TMPDIR environment variable are not supported. 

The −t 2,name option is not supported. 

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, does 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’, only level 1 optimizations are handled.  If opt is ’2’, all optimizations are performed.  The option +O2 is the same as −O. 

+L or −W c,-L
Enable the listing facility and any #listing pragmas. A straight listing prints:

• A header on the top of each page

• Line numbers

• The nesting level of each statement

• The postprocessed source file with expanded macros, included files, and no user comments (unless the -C option is used). 

+m or −W c,-m
Cause the identifier maps to be printed. First, all global identifiers are listed, then all the other identifiers are listed by function at the end of the listing. For struct and union members, the address column contains B@b, where B is the byte offset and b is the bit offset. Both B and b are in hexadecimal.

+o or −W c,-o
Cause the code offsets to be printed in hexadecimal; they are grouped by function at the end of the listing.

+Rnum or −W c,-Rnum
Allow only the first num ’register’ variables to actually have the ’register’ class. Use this option when the register allocator issues an "out of general registers" message.

+wn or −W c,-wn
Specify the level of the warning messages. The value of n can be one of the following values:

1 All warnings are issued. 

2 Only warnings indicating that code generation might be affected are issued; equivalent to the compiler default without any w opts. 

3 No warnings are issued; equivalent to the −w option. 

FILES

file.c input file

file.o object file

a.out linked output

/tmp/ctm∗ default temporary files

/usr/tmp/ctm∗ default temporary files

/lib/cpp preprocessor

/bin/as assembler, as(1)

/bin/ld link editor, ld(1)

/lib/crt0.o runtime startoff

/lib/mcrt0.o startoff for profiling via prof(1)

/lib/gcrt0.o startoff for profiling via gprof(1)

/lib/libc.a standard C library, see Section (3) of this manual

/usr/include standard directory for #include files

Series 300

/lib/ccom10 compiler (MC68010 version)

/lib/ccom20 compiler (MC68020 version)

/lib/c210 optimizer (MC68010 version)

/lib/c220 optimizer (MC68020 version)

/bin/as10 assembler (MC68010 version)

/bin/as20 assembler (MC68020 version)

Series 800

/lib/ccom compiler, cc

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

/usr/lib/nls/$LANG/cc.cat
C Compiler message catalog

SEE ALSO

adb(1), as(1), cdb(1), cpp(1), gprof(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 file names, messages. 
Series 800 does not support 16-bit data.

Hewlett-Packard Company  —  May 11, 2021

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