Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ CC.1.old(1) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

helpview(1X)

gprof++(1)

c++filt(1)

gprof(1)

monitor(3C)

xdb(1)

cdb(1)

adb(1)

as(1)

cpp(1)

cc(1)

ld(1)

matherr(3M)

strip(1)

crt0(3)

end(3C)

exit(2)

CC(1)

NAME

CC − C++ translator/compiler

SYNOPSIS

CC [ options ] files

DESCRIPTION

CC (capital CC) is the HP-UX C++ translator/compiler.  In translator mode CC translates C++ source code to C source code.  In compiler mode CC compiles C++ source code directly to object code. 

The command uses cpp(1) for preprfocessing, cfront for syntax and type checking, as well as for code generation in compiler mode, and cc(1) for code generation in translator mode. 

CC accepts several types of arguments as files:

• Arguments whose names end with .c or .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 or .C.  However, if a single C++ source 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.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 and are passed to cc(1) to be included in the link operation. 

Arguments and options can be passed to the translator/compiler through the CXXOPTS environment variable as well as on the command line.  The translator/compiler picks up the value of CXXOPTS and places its contents before any arguments on the command line.  For example (in sh(1) notation),

CXXOPTS=−v
export CXXOPTS
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:

−Alevel Where level can be either a or c. 

a Request ANSI mode HP C++ preprocessor (the default mode). 

c Request compatibility mode HP C++ preprocessor. 

−b Cause the linker ld(1) to create a shared library rather than a normal executable file.  Object files processed with this option must contain position independent code (PIC).  For details see ld(1) and the manual "Programming on HP-UX". 

−c Suppress the link edit phase of the compilation, and force an object (.o) file to be produced for each .c or .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.

−depth Instruct the runtime system to traverse the shared library list in a depth first manner as opposed to the default left to right search when calling static constructors. The traversal of the static constructor chain within each shared library is not impacted by this option. 

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

−F Run only cpp(1) and cfront on the C++ source files, and send the result to standard output.  The −F option implies the +T option. 

−Fc Like the −F option, but the output is C source code suitable as a .c file for cc(1).  This option is equivalent to −F and the +L option. The −Fc option implies the +T option. 

−.suffix Instead of using standard output for the −E, −F or −Fc options, place the output from each .c file into a file with the corresponding .suffix. 

−g Cause the compiler to generate additional information needed by the symbolic debugger.  This option cancels the effect of any specified optimization options. 

−g1 Cause the compiler to generate less symbolic debug information, thereby decreasing the size of the object file.  This option should be used when an entire application is compiled with the −g1 option. 

Specifically, the −g option emits full debug information for every class referenced in a file, which can result in redundant information.  The −g1 option causes complete class information to be generated only for the file in which it is defined (the first non-inline, non-pure, virtual function specifies definition).  If an entire application is compiled with the −g1 option no debugger functionality is lost. 

−G Prepares the object file for profiling with 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.  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 with level 2 optimization.  Equivalent to +O2. 

−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.  Also see ld(1) for additional 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 or Cpp.ansi)

C Translator/compiler body (standard suffix is cfront)

r Compile-time template processor (standard suffix is c++ptcomp)

i Link-time template processor (standard suffix is c++ptlink)

c Compiler body in translator mode (standard suffix is ccom)

0 Same as c

a Assembler (standard suffix is as)

l Linker (standard suffix is ld)

b Code generator in translator mode (standard suffix is cc)

m Merge tool (standard suffix is c++merge)

f Filter tool (standard suffix is c++filt)

P Patch tool (standard suffix is c++patch)

x All subprocesses. 

−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 some options, a shorthand notation for this mechanism can be used by placing "+" in front of the option name 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. 

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

+A Cause the linker ld(1) to use only archive libraries for all occurrences of the −l option.  Also inform the C++ runtime environment that no shared libraries will be used by the program. 

+a[01]
The translator/compiler can generate either ANSI C style or "Classic C" (also known as K&R C) style declarations.  The +a option specifies which style of declarations to produce.  The +a0, the default, causes the translator/compiler to produce "Classic C" style declarations.  The +a1 option causes the translator/compiler to produce ANSI C style declarations. 

+d Prevents the expansion of inline functions. 

+e[01]
Optimize a program to use less space by ensuring that only one virtual table is generated per class.  The +e1 option causes virtual tables to be external and defined, that is, initialized.  The +e0 option causes virtual tables to be external byte only declared, that is, uninitialized.  When neither option is used, virtual tables will be static, that is, there will be one per file.  Usually, +e1 is used to compile one file that includes class definitions, while +e0 is used on all the other files including those class definitions. 

+eh Enable exception handling.  Exception handling is supported in both compiler mode and translator mode, and such object files can be intermixed.  Code compiled with +eh option is NOT link compatible with code that has not been compiled with +eh option.  Attempt to link these two kinds of object files together will generate link (or run time) warning.  Use the +eh option when linking objects compiled with +eh option.  With the +eh option the CC driver will automatically link in the +eh version of the run-time library. 

+i Cause an intermediate ..c C language source file to be produced in the current directory.  The +i option implies the +T option. 

+L Generate source line number information using the format "#line %d" instead of "#%d". 

+m Provide maximum compatibility with the AT&T C++ implementation.  HP C++ provides optimizations and additional functionality which may not be compatible with other C++ implementations. 

+p Disallow all anachronistic constructs.  Ordinarily the translator/compiler gives warnings about anachronistic constructs; using the +p option, the translator/compiler will not compile code containing anachronistic constructs.  See the AT&T C++ Reference Manual for a list of anachronisms. 

+T Requests translator mode.  In translator mode, C++ source code is translated to C code which is then compiled by cc(1) to object code. 

+w Warn about all questionable constructs.  Without the +w option, the translator/compiler issues warnings only about constructs that are almost certainly problems. 

+xfile Read a file of sizes and alignments.  Each line contains three fields: a type name, the size (in bytes), and the alignment (in bytes).  This option is useful for cross compilations and for porting the translator. 

+z,+Z
Cause the translator/compiler to generate position independent code (PIC) for use in building shared libraries.  The options −g and −G are ignored if used when generating PIC.  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". 

The following options are recognized by CC to support the template instantiation system.  Also, refer to the note on templates below. 

−pta Instantiate an entire template class rather than only those members that are used.  This option is incompatible with the −pts option. 

−pth Specifies that template instantiation files should be created using short file names. (Template instantiation files are object files created in the template repository by c++ptlink.) Use this option if your version of HP-UX has not been upgraded to support long file names. HP C++ creates template instantiation files using long file names by default. See convertfs(1M) for more information about long file names. 

−ptH"list"
Specifies a list of file name extensions that template declaration files(header files) can have.  When compiling or instantiating templates, the compiler searches for header files with these extensions in the order the extensions are listed. For example, −ptH".h .H" specifies that template declaration header files can have extensions of .h or .H.  By default, HP C++ uses the following list of extensions: ".h .H .hxx .HXX .hh .HH .hpp". 

−ptn Change the default instantiation behavior for one-file programs to that of larger programs, where instantiation is broken out separately and the repository updated.  One-file programs normally have instantiation optimized so that templates are instantiated directly into the application object file itself. 

−ptrpathname
Specify a repository, with ./ptrepository the default.  If several repositories are given, only the first is writable, and the default repository is ignored unless explicitly named. 

−pts Split instantiations into separate object files, with one function per object (including overloaded functions), and all static data and virtual functions grouped into a single object.  This option is incompatible with the −pta option.  The −pts option can only be used to split up needed functions rather than all functions. 

−ptS"list"
Specifies a list of file name extensions that template definition files(source files) can have.  When compiling or instantiating templates, the compiler searches for source files with these extensions in the order the extensions are listed. For example, −ptS".c .C" specifies that template definition files can have extensions of .c or .C.  By default, HP C++ uses the following list of extensions: ".c .C .cxx .CXX .cc .CC .cpp". 

−ptv Turn on verbose or verify mode, which displays each phase of instantiation as it occurs.  With verbose mode, the reason why instantiation is done and the exact CC command used are displayed. 

Any other options encountered generate a warning to standard error. 

Other arguments are taken to be HP C++ compatible object files, typically produced by an earlier CC run, or perhaps libraries of HP C++ compatible routines.  These files, together with the results of any compilations specified, are linked (in the order given) to produce an executable program with the name a.out. 

NOTES

Pointers

Accessing the object of a NULL (zero) pointer is technically illegal, 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. 

Templates

The template instantiation system has dependencies on options passed to CC on the command line.  Options which are normally specified to compile an application, such as −I and −D, must also be specified at link time so that the template instantiation system can instantiate template types with the appropriate header files and options. 

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++ translator/compiler 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. 

DEPENDENCIES

Series 300/400
The −z option is not supported. 

The −g and −g1 options are incompatible with optimization.  If both debug and optimization are specified, the debug option takes precedence. 

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

HP C++ supports the following 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. 

+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 code for the MC68881, MC68882 or MC68040.  Library routines are referenced for matherr capability. 

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

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

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

2 Peephole optimizer (standard suffix is c2.cxx)

O Optimizing compiler body (standard suffix is cfront2)

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

The −g and −g1 options are incompatible with optimization.  If both debug and optimization are specified, the debug option takes precedence. 

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. 

+DAmodel Generate code for a specific version of the PA-RISC architecture.  model is required.  The default code generated for the Series 800 is PA-RISC version 1.0.  The default code generated for the Series 700 is PA-RISC version 1.1.  The default code generation may be overridden using the CXXOPTS environment variable or the command line option +DA.  model must be one of the following generic specifications:

1.0 PA-RISC version 1.0 or higher.  This is the default for all Series 800 models. 

1.1 PA-RISC version 1.1.  This is the default for all Series 700 models. 

Object code generated for PA-RISC 1.1 will not execute on PA-RISC 1.0 implementations.  The compiler determines the target architecture using the following precedence:

1.  Specification of +DA in the CXXOPTS environment variable. 

2.  Command line specification of +DA. 

3.  The default as mentioned above. 

+DSmodel Perform instruction scheduling appropriate for a specific implementation of the PA-RISC architecture.  model is required.  model must be one of the following generic specifications:

1.0 Perform PA-RISC version 1.0 tuned scheduling. 

1.1 Perform PA-RISC version 1.1 tuned scheduling. 

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(2).  This option affects only performance of the object code by scheduling the code based on the specific latencies of the target implementation.  The resulting code will execute correctly on other implementations (subject to the +DA option described above). 

+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.  If opt is s, suppress optimizations which tend to increase the generated code size.  Currently, these optimizations include software pipelining and loop unrolling. 

+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, and 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 will be printed giving the name of the procedure and the number of basic blocks it contains, and level 1 optimization will be done.  The default value for this limit, if this option is not present, is 500.  This option implies level 2 optimization (equivalent to -O or +O2 ). 

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

FILES

file.C input file

file.o object file

a.out linked output

/usr/lib/cfront compiler/translator

/bin/cc C compiler, cc(1)

/usr/lib/Cpp compatibility preprocessor

/usr/lib/Cpp.ansi ANSI preprocessor (default)

/bin/as assembler, as(1)

/bin/ld link editor, ld(1)

/usr/lib/c++filt C++ name filter tool, c++filt(1)

/usr/lib/c++merge C++ debug merge tool

/usr/lib/c++patch C++ patch tool

/usr/lib/c++ptcomp C++ template type merge tool

/usr/lib/c++ptlink C++ template instantiation processor

/lib/crt0.o runtime startoff

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

/usr/lib/libC.sl standard C++ library (shared version)

/usr/lib/libC.a standard C++ library

/usr/lib/libC.ansi.sl ANSI standard C++ library (shared version)

/usr/lib/libC.ansi.a ANSI standard C++ library

/usr/lib/libcxx.a C++ support library. 

/usr/include/CC standard directory for C++ #include files

/usr/lib/nls/$LANG/CC.cat
C++ compiler message catalog

Series 300/400

/usr/lib/cfront2 optimizing compiler

/usr/CC/lib/cpass2.cxx
pass 2 of the optimizing code generator

/usr/CC/lib/c1.cxx global optimizer

/usr/CC/lib/c2.cxx peephole optimizer

/usr/CC/bin/as.cxx assembler

Series 700/800

SEE ALSO

Online help:

helpview(1X) HP Vue online help system for C++.  Select the "?" icon on the HP Vue front panel, or type the command helpview, which is in /usr/vhelp/bin. 

C++ tools:

gprof++(1) display call graph profile data for C++

c++filt(1) C++ name filter tool

Profiling and debugging tools:

gprof(1) display call graph 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

cc(1) C compiler

ld(1) invoke the link editor

Miscellaneous:

matherr(3M) trap math errors 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:

Bjarne Stroustrup, Margaret A. Ellis, The Annotated C++ Reference Manual, Addison-Wesley, 1990.

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

  —  May 04, 1993

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