cc(1)
NAME
cc, c89 − C compiler
SYNOPSIS
cc [options] files
c89 [options] files
DESCRIPTION
cc is the HP-UX C compiler. c89 is the HP-UX POSIX -conformant 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 (see the -P option below). They are compiled without again invoking cpp (see 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
Note that in the following list, the cc and c89 options -A , -G , -g , -O , -p , -v , -y , +z , and +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. 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 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 the fourth bullet item 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() at the start (see monitor(3C)) and arranges to write out a mon.out file at normal termination of execution of the object program. prof can then be used to generate an execution profile (see prof(1)).
-P Run only cpp on the named C files and leave the result on corresponding files suffixed .i. The -P option is also passed along to cpp.
-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.
-Wx,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 that 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 -G and -p options are ignored if +z or +Z is used. Normally, +z should be used to generate PIC; however, when certain limits are exceeded, +Z is required to generate PIC. The ld linker 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 assumed 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 can 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, then invokes the ld link editor 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 placed in file 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() (see exit(2)) or leave the function main() with a return expression; construct.
DEPENDENCIES
Series 300/400
Note that in the following list, the 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 -Wc,-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 in-line 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 in-lining 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 in-lined 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 or cpass1.ansi if compiling with -Aa)
1 Second pass of the compiler with level 2 optimization (standard suffix is cpass2)
c Compiler (standard suffix is ccom or ccom.ansi if compiling with -Aa)
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 in-lining. The functions that are ’in-lined’ 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
Note that in the following list of Series 700-and-800-specific cc and c89 options, -Ae, +df, +e, +f, +ES, +I, -J, +m, +O, +P, +pgm, and +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() (see 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.
-Ae Extended ANSI mode. Same as -D_HPUX_SOURCE and -Aa and allows the following extensions: $ characters can appear in identifier names, and enum declarations can include integral type specifiers. Additional extensions may be added to this option in the future.
+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 can be overridden using the CCOPTS environment variable or the command line option +DA. architecture can be either a model number (e.g., 750 for the HP 9000/750 or 870 for the HP 9000/870) or one of the following generic specifications:
1.0 Precision Architecture RISC, version 1.0 or higher. This is the default for all Series 800 models.
1.1 Precision Architecture RISC, version 1.1. This is the default for all Series 700 models.
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. The architecture is determined by uname() (see uname(2)). architecture can be either a model number (e.g, 750 for the HP 9000/750 or 870 for the HP 9000/870) or one of the following generic specifications:
1.0 Precision Architecture RISC, version 1.0.
1.1 Precision Architecture RISC, version 1.1, general scheduling for Series 700 systems.
+dfname Specify profile database file name for profile based optimizations. The default is flow.data if name is not specified. No white space is permitted between +df and name. Data for more that one application can be kept in the same file. +df requires the specification of either +I or +P. See ld(1), +P, +I, and +pgm for more details.
+e Enables HP value-added features while compiling in ANSI C mode, -Aa. This option is ignored with -Ac because these features are already provided. Features enabled:
• Long pointers
• Integral type specifiers can appear in enum declarations.
• The $ character can appear in identifier names.
• 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 in-line code when performing function pointer comparisons. Care should be taken when using this option and pointers to shared library routines are being compared.
+f Inhibit the automatic promotion of float to double when evaluating expressions. This differs from +r (see below) in that parameters and function return values are promoted. This option is ignored and a warning is produced if ANSI mode is in effect.
+FPstring Specifies how the run time behavior for floating-point operations should be initialized at program start-up. The default is that all behaviors are disabled. See ld(1) for specific values of string. To dynamically change these settings at run time, refer to fpgetround(3M).
+I Instrument the application for profile based optimization. See ld(1), +P, +df, and +pgm for more details. This option is incompatible with -G, -g, +m, +o, -p, -S, and -y.
-J Improve run-time performance of standard C routines by altering error condition checking. This option generates in-line assembly for the routines strcpy(), sqrt(), and fabs(), under certain conditions. The matherr() function is not called nor is errno set on error conditions for the above-mentioned routines (see matherr(3M)). This option may also alter the error handling of many routines declared in <math.h>. -J may in-line or alter the error handling of additional routines in future releases.
+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 Cause the identifier maps to be printed. First, locals by function are listed, then all global identifiers are listed. All other identifiers are then 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. This option is incompatible with +I and +P.
+o Cause the code offsets to be printed in hexadecimal; they are grouped by function at the end of the listing. This option is incompatible with +I and +P.
+Oopt Invoke optimizations selected by opt. Defined values for opt are:
0 Perform no optimizations. This is the default.
1 Perform optimizations within basic blocks only.
2 Perform level 1 and global optimizations. Same as -O.
3 Perform level 2 as well as interprocedural global optimizations. Also sends -O to the linker (see ld(1)).
E Same as -O but notify the optimizer that floating point traps have been enabled. Prevents the optimizer from performing loop-invariant code motion on floating point operations.
m1 Same as -O and allow the optimizer to assume no parameters in function calls refer to the same memory.
s Same as -O but notify the optimizer to suppress any optimizations which might result in a significant code-size expansion.
V Same as -O but assume all global memory references are to be treated as if they were declared with the keyword volatile, meaning that references to global objects cannot be optimized away.
+Obbnum Specify the maximum number of basic blocks allowed in a procedure which is to be optimized at level 2. 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 -O.
+P Optimize the application based on profile data found in the database file flow.data, produced by compilation with +I. See ld(1), +I, +df, and +pgm for more details. This option is incompatible with -G, -g, +m, +o, -p, -S, and -y.
+pgmname Specify a profile database lookup name within the database file name. No white space is permitted between +pgm and name. +pgm requires that either +I or +P be specified. See also ld(1), +P, +I, and +df for more details.
+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 ANSI mode is in effect (see also +f).
+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.
+unum Allow pointers to access non-natively aligned data. This option alters the way that the compiler accesses dereferenced data. Use of this option may reduce the efficiency of generated code.
1 Assume single byte alignment. Dereferences are performed with a series of single-byte loads and stores.
2 Dereferences are performed with a series of two-byte loads and stores.
4 Dereferences are performed with a series of four-byte loads and stores.
+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 (see as(1))
/bin/ld link editor (see 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 in-liner
/lib/c.c1 global optimizer
/lib/c.c2 peephole optimizer
Series 700/800
/lib/icrt0.o Startoff for Instrumentation via +I
/usr/lib/nls/$LANG/cc.cat
C Compiler message catalog
/usr/lib/uccom Stand-alone code generator
/usr/lib/sched.models processor implementation file
SEE ALSO
Program management and analysis tools:
lint(1) C program checker/verifier
cb(1) C program beautifier, formatter
cxref(1) generate C program cross-reference
Profiling and debugging tools:
gprof(1) display call graph profile data
prof(1) display profile data
monitor(3C) prepare execution profile
xdb(1) C, C++, FORTRAN, and Pascal symbolic debugger
cdb(1) C, C++, FORTRAN, and Pascal symbolic debugger
adb(1) absolute debugger
System tools:
as(1) translate assembly code to machine code
cpp(1) invoke the the C language preprocessor
ld(1) invoke the link editor
Miscellaneous:
matherr(3M) trap math errors
fpgetround(3M) floating-point mode-control functions
strip(1) strip symbol and line number information from an object file
crt0(3) execution startup routine
end(3C) symbol of the last locations in program
exit(2) termination of a process
Tutorials and Standards Documents:
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: POSIX.2
Hewlett-Packard Company — HP-UX Release 9.0: August 1992