Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

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)

crt0(3)

end(3C)

monitor(3C)

matherr(3M)

cc(1)

NAME

cc, c89 − C compiler

SYNOPSIS

cc [options] files
c89 [options] files

Remarks:

This entry supersedes the printed cc(1) entry in the HP-UX Reference for Release 8.05, and includes new functionality not described in the printed entry. 

DESCRIPTION

cc is the HP-UX C compiler.  c89 is the HP-UX POSIX conforming C compiler.  Both accept 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 basename, 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 assumed 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 basename, but suffixed .o instead of .i. 

• Arguments of the form −lx cause the linker to search the library libx.sl or 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 reads the value of CCOPTS and divides these options into two sets; those options which appear before a vertical bar (|), and those options which appear after the vertical bar. The first set of options are placed before any of the command-line parameters to cc; the second set of options are placed after the command-line parameters to cc. If the vertical bar is not present, all options are placed before the command-line parameters. For example (in sh(1) notation),

CCOPTS ="−v | −lmalloc"
export CCOPTS
cc −g prog.c

is equivalent to

cc −v −g prog.c −lmalloc

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

Options

It should be noted that from the cc and c89 options; −A, −G, −g, −O, −p, −v, −y, +z, +Z are not supported by the C compiler provided as part of the standard HP-UX operating system.  They are supported by the C compiler sold as an optional separate product. 

The following option is recognized only 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 compatible with HP-UX releases prior to 7.0.  (See The C Programming Language, First Edition by Kernighan and Ritchie). This option is currently the default. The default may change in future releases.

a Compile under ANSI mode ( ANSI programming language C standard ANS X3.159-1989).  When compiling under ANSI mode, header files define only those names specified by the standard.  To get the same name space as in compatibility mode (−Ac), define the symbol _HPUX_SOURCE. 

The following options are recognized by both cc and c89:

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

−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.sl or libx.a.  The −L option causes cc to search in dir before searching in the default locations.  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 with level 2 optimization.  Equivalent to +O2. 

−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.  See strip(1) for more details. 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 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 (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...]
Pass the argument[s] argi to subprocess 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,

−Wl,−a,archive

causes the linker to link with archive libraries instead of with shared libraries.  See ld(1) for details. 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

−Wc,−M

+M is the Series 300/400 option which causes the compiler to generate calls to the math library instead of generating code for the MC68881 or MC68882 math coprocessor.  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.  The −z and −Z are linker options.  See ld(1) for more details.

+z,+Z Both of these options cause the compiler to generate position independent code (PIC) for use in building shared libraries.  The options −g , −G , −p , and −y are ignored if +z or +Z are used.  Normally, +z should be used to generate PIC; however, when certain limits are exceeded, +Z is required to generate PIC.  The linker ld(1) issues the error indicating when +Z is required.  If both +z and +Z are specified, only the last one encountered applies.  For a more complete discussion regarding PIC and these options, see the manual Programming on HP-UX.

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 compatibility mode ( −Ac ) 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. 

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. 

DIAGNOSTICS

The diagnostics produced by C itself are intended to be self-explanatory.  Occasionally, messages may be produced by the preprocessor,  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.sl or 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/400

It should be noted that from the following Series 300/400-specific cc and c89 options; +e, +O, +y are not supported by the C compiler provided as part of the standard HP-UX operating system.  They are supported by the C compiler sold as an optional separate product. 

The −z option is not supported. 

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

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

+bfpa Cause the compiler to generate code that uses the HP98248A or HP98248B 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 or MC68882 math coprocessor or the MC68040. 

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

• $ as an identifier character

• Accept embedded assembly code

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

+M Cause the compiler not to generate inline floating point code for the MC68881 , MC68882 or MC68040.  Library routines are referenced for matherr capability. 

+NsecondaryN Adjust the initial size of internal compiler tables.  secondary is one of the letters from the set {abdepstw}, and N is an integer value.  secondary and N are not optional.  The Series 300/400 compiler automatically expands the tables if they become full.  The +N option is supported only for backwards compatibility. 

+Oopt Invoke optimizations selected by opt. If opt is 1, only level 1 optimizations are handled.  If opt is 2, all optimizations except inlining 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.  If opt is 3, all level 2 optimizations are performed and in addition, code for certain functions is generated in line rather than calling the function.  Functions that are ’inlined’ are strcpy, the transcendental functions available on the MC68881 or MC68882 math coprocessor, and certain user-defined functions.  For a complete discussion of the various optimization levels, see the C Programmers Guide.

+s By default, compilation subprocesses are run concurrently and, in ANSI mode, cpp and ccom (cpass1) are merged into a single subprocess.  This results in better compile time performance except when available compilation memory is scarce.  Invoking this option executes the processes sequentially and executes cpp and ccom (cpass1) as distinct processes, thereby minimizing memory consumption. 

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

2 Peephole optimizer (standard suffix is c.c2)

i Procedure integrator (standard suffix is c.c0)

−v Enables verbose mode in the global optimizer as well. 

−W c,−F Perform some function inlining.  The functions that are ’inlined’ are strcpy, and the transcendental functions available on the MC68881 or MC68882 math coprocessor. 

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

−W g,−All Cause the global optimizer to apply all optimizations.  By default, the global optimizer does not attempt certain optimizations when the complexity of a function exceeds a certain limit.  This option causes the global optimizer to unconditionally apply all optimizations. 

+y The default behavior for generating symbolic debugging information (−g) and static analysis information (−y) is to generate such information only for items referenced in the file being compiled.  For example, if a structure is defined in some included header file yet never referenced, no symbolic debugging information or static analysis information is generated for that structure.  The +y option causes the compiler to generate symbolic debugging information or static analysis information for all items, whether referenced or not.  The +y option is only valid when used with −g or −y. 

Series 700/800

It should be noted that from the following Series 700-and-800-specific cc and c89 options, +e, +ES, +O, +y are not supported by the C compiler provided as part of the standard HP-UX operating system.  They are supported by the C compiler sold as an optional separate product. 

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

The −g option is incompatible with optimization.  If both debug and optimization are specified, only the first option encountered takes effect. 

The −y option is incompatible with optimization.  If both static analysis and optimization are specified, only the first option encountered takes effect. 

The −s option is incompatible with the −g , −G , −p , and −y options.  If −s is specified along with any of the above options, the −s option is ignored, regardless of the order in which the options were specified. 

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 c options. 

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

+DAarchitecture Generate code for the architecture specified.  architecture is required.  The default code generated for the Series 800 is PA_RISC_1.0.  The default code generated for the Series 700 is PA_RISC_1.1.  The default code generation may be overriden using the CCOPTS environment variable or the command line option +DA.  Defined values for architecture are:

1.0 Precision Architecture RISC, version 1.0. 

1.1 Precision Architecture RISC, version 1.1. 

The compiler determines the target architecture using the following precedence:

1.  Command line specification of +DA. 

2.  Specification of +DA in the CCOPTS environment variable. 

3.  The default as mentioned above. 

+DSarchitecture Use the instruction scheduler tuned to the architecture specified.  architecture is required.  If this option is not used, the compiler uses the instruction scheduler for the architecture on which the program is compiled.  Defined values for architecture are:

1.0 Precision Architecture RISC, version 1.0. 

1.1 Precision Architecture RISC, version 1.1, general scheduling for the series 700. 

1.1a Scheduling for specific models of Precision Architecture RISC, version 1.1. 

+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

+ESlit Place string literals and const-qualified data into read-only memory. This may save space in the resulting executable by coalescing identical string literals, and can promote data sharing in a multi-user application.

+ESsfc Replace millicode calls with inline code when performing function pointer comparisons.  Care should be taken when using this option and pointers to shared library routines are being compared. 

+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 shows 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 3, interprocedural global optimizations are performed, as well as all level 2 optimizations.  If compiling and linking are performed in one step with opt set to 3, the −O option is sent to the linker (see ld (1)).  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. 

+Obbnum Specify the maximum number of basic blocks allowed in a procedure which is to be optimized at level 2.  A basic block is a sequence of code with a single entry point and single exit point, with no internal branches.  Optimizing procedures with a large number of basic blocks can take a long time and may use a large amount of memory.  If the limit is exceeded, a warning is emitted and level 1 optimization is performed for the remainder of the function.  The default value for this limit is 500.  This option implies level 2 optimization (equivalent to −O or +O2). 

+OS Invoke software pipelining and register reassociations.  This option implies level 2 optimization if no other optimization level is specified. 

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

+u Allow pointers to access members of non-natively aligned structs and unions. 

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

+y Generate static analysis information for all global identifiers not seen in the original source file.  This option only has effect if used in conjunction with the −y 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 C 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 (archive version), see HP-UX Reference Section (3). 

/lib/libc.sl standard C library (shared version), see HP-UX Reference Section (3). 

/lib/libp/libc.a C library for profiled programs (archive version)

/usr/include standard directory for #include files

Series 300/400

/lib/ccom.ansi ANSI C compiler

/lib/cpass1 pass 1 of the optimizing compiler

/lib/cpass1.ansi pass 1 of the optimizing ANSI compiler

/lib/cpass2 pass 2 of the optimizing compiler

/lib/c.c0 procedure inliner

/lib/c.c1 global optimizer

/lib/c.c2 peephole optimizer

Series 700/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), crt0(3), end(3C), monitor(3C), matherr(3M). 

B. W. Kernighan and D. M. Ritchie, The C Programming Language, Prentice-Hall, 1978.

American National Standard for Information Systems − Programming language C, ANS X3.159-1989

STANDARDS CONFORMANCE

cc: SVID2, XPG2, XPG3

c89:

Hewlett-Packard Company  —  HP-UX Release 8.05 (revised)

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