Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ cc(1) — HP-UX 7.01

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)

NAME

cc − C compiler

SYNOPSIS

cc [ options ] files

DESCRIPTION

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

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

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

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

• Arguments  of the form −lx that cause the linker to search the library libx.a in an attempt to resolve currently unresolved external references.  Because a library is searched when its name is encountered, placement of a −l is significant.  If a file contains an unresolved external reference, the library containing the definition must be placed after the file on the command line.  See ld(1) for further details.

• All other arguments, such as those  whose names end with .o or .a, are taken to be relocatable object files that are to be included in the link operation. 

Arguments and options 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:

−Amode Specify the compilation standard to be used by the compiler.  The mode can be one of the following letters:

c Compile in a mode compatibile with HP-UX releases prior to 7.0.  (See The C Programming Language, First Edition by Kernighan and Ritchie). This option is the default for release 7.0 of HPUX.  However the default may change in future releases. 

a Compile under ANSI mode (December 7, 1988 Draft proposed ANSI C standard.) 

−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.  This option cancels the effect of any specified optimization options. 

−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 Refer to item (4) at the beginning of the DESCRIPTION section. 

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

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

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

The 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)

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. 

−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 c,−M

causes the compiler to generate calls to math library routines instead of inline code for the MC6881 math coprocessor.  For some options, a shorthand notation for this mechanism can be used by placing "+" in front of the option name as in

+M

which is equivalent to the previous option example.  Some other 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 Generate additional information needed by static analysis tools, and ensure that the program is linked as required for static analysis.  This option is incompatible with optimization. 

−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 allows 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 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 first edition of "The C Programming Language", by Kernighan and Ritchie, and the various addenda to it, are intentionally ambiguous in some areas.  HP-UX specifies some of these below for compatability mode compilations. 

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 compiles the C file prog.c, to create a prog.o file, and 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 can 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 −A, −z, and −y options are not supported. 

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

The compiler  supports the following options, which may also be passed to it from cc using the −W c option. 

+bfpa Cause the compiler to generate code that uses the HP98248A 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. 

+ffpa Cause the compiler to generate code for the HP98248A floating point accelerator card.  This code does not run unless the card is installed. 

+M Cause the compiler not to generate inline code for the MC68881 math coprocessor.  Library routines are referenced for matherr capability. 

+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 Initial 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 2000 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. 

+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 −O option is equivalent to +O2.  If opt is V, optimization level 2 is selected, but all global variables and objects dereferenced by global pointers are treated as if they were declared with the keyword “volatile,” meaning that references to the object cannot be optimized away. 

−tx,name Specify additional subprocess identifiers. 

0 First pass of the compiler with level 2 optimization.  It is not the same as subprocess c (standard suffix is cpass1). 

1 Second pass of the compiler with level 2 optimization (standard suffix is cpass2). 

g Level 2 global optimizer. (standard suffix is c1)

2 Peephole optimizer (standard suffix is c2)

−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.  This option is incompatible with optimization. 

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

Nonsharable, executable files generated with the −N option cannot be executed via exec(2). For details and system defaults, see ld(1).

The compiler supports the following additional options.  The +opt1 notation can be used as a shorthand notation for some −W options. 

+a or −W d,−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 cannot be linked unless they contain the equivalent information.

+e or −W c,−e
Enables HP value added features  while compiling in ANSI C mode, −Aa.  This option is ignored with −Ac since these features are already provided.  Features enabled:

• long pointers

• missing parameters on intrinsic calls

+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). 

If the −Aa option is used to compile under ANSI C, the listing will show the original source file rather than the postprocessed source file. 

+Lp Print a listing as described above, but show the postprocessed source file even if one of the ANSI compilation levels is selected.  This option is ineffective if the −y 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.

+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.  If opt is V all memory references are treated as if they were declared with the keyword “volatile,” meaning that references to the object cannot be optimized away. 

+r or −W c,-r Inhibits the automatic promotion of float to double when evaluating expressions and passing arguments.  This option is ignored and a warning produced if the −Aa option is in effect. 

+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/ccom compiler

/lib/cpp preprocessor

/lib/cpp.ansi preprocessor for ANSI C

/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 HP-UX Reference Section (3). 

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

/usr/include standard directory for #include files

Series 300

/lib/cpass1 pass 1 of the optimizing compiler

/lib/cpass2 pass 2 of the optimizing compiler

/lib/c1 global optimizer

/lib/c2 peephole optimizer

/bin/as20 assembler

Series 800

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

Draft Proposed American National Standard for Information Systems − Programming language C, December 7, 1988, Doc. No. X3J11/88-090

EXTERNAL INFLUENCES

Environment Variables

When the −Y option is invoked, LC_CTYPE determines the interpretation of string literals and comments as single and/or multi-byte characters. 

LANG determines the language in which messages are displayed. 

If LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable.  If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.  If any internationalization variable contains an invalid setting, cc behaves as if all internationalization variables are set to "C".  See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported. 

STANDARDS CONFORMANCE

cc: SVID2, XPG2, XPG3

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

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