HPlogo HP C++ Programmer's Guide: HP 9000 Series Workstations and Servers > Chapter 3 Compiling and Executing HP C++ Programs

Compiling with the CC Command

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

Use the CC command to invoke the HP C++ compiling system. The CC command invokes a driver program that runs the phases of the compiling system according to the file names and command line options that you specify.

Setting Your Path to the CC Command

The CC command is normally installed in the directory /usr/bin(/opt/CC/bin for HP-UX 10.x C++ versions). So that you can use the CC command, you should ensure that your PATH environment variable includes this directory. You can do this with the following Bourne or Korn shell commands:

PATH=/usr/bin:$PATH

export PATH

You should modify the command that sets the PATH variable in the appropriate shell script file, either .profile or .login, in your home directory.

Syntax

The CC command has the following format:

CC [ options | files ]

where:

options

is zero or more compiler options and their arguments, if any. Single-character options that do not accept additional arguments can be grouped under either a single minus or plus sign.

files

is one or more path names, separated by blanks. Each file is either a source file, a preprocessed source file, an assembly language source file, an object file, or a library file.

Specifying Files to the CC Command

HP C++ source files must be named with extensions beginning with either .c or .C, possibly followed by additional characters. If you compile only, each HP C++ source file produces an object file with the same name as the source file, except that the extension beginning with .c or .C is changed to a .o extension. However, if you compile and link a single source file into an HP C++ program in one step, the .o file is automatically deleted.

CAUTION: While file extensions other than .c or .C are permitted for portability from other systems, it is recommended that your source files have extensions of .c and .C only, without additional characters. Other endings may not be supported by HP tools and environments.

Files with names ending in .i are assumed to be preprocessor output files (refer to the -P compiler option). Files ending in .i are processed the same as .c or .C files, except that the preprocessor is not run on the .i file before the file is compiled.

Files with names ending in .s are assumed to be assembly source files. The compiler invokes the assembler to produce .o files from these.

Files with .o extensions are assumed to be relocatable object files that are to be included in the linking. All other files are passed directly to the linker by the compiler.

Unless you use the -o option to specify otherwise, all files that the CC compiling system generates are put in the working directory, even if the source files came from other directories.

Specifying Options to the CC Command

The CC interface supports several options that you can use to control the operation of the compiling system. You can specify these options on the CC command line before, after, or interspersed with file arguments.

The CC options have one of the two prefixes, - or +.

Each compiler option has the following format:

-optionname [optionarg]

or

+optionname [optionarg]

where:

optionname is the name of a compiler option

and

optionarg is the argument to optionname.

See also "The CXXOPTS Environment Variable" in this chapter for another way of specifying options to the CC command.

An Example of Using a Compiler Option

By default, the CC command names the executable file a.out. For example, given the following command line,

CC demo.C

the executable file is named a.out, just as is the case in compiling a C program with the cc command.

You can use the -o option to override the default name of the executable file produced by CC. For example, suppose my_source.C contains C++ source code and you want to create an executable file named my_executable. Then you would use the following command line:

CC -o my_executable my_source.C

Concatenating Options

You can concatenate some options to the CC command under a single prefix. The longest substring that matches an option is used. Only the last option can take an argument. You can concatenate option arguments with their options if the resulting string does not match a longer option.

For example, suppose you want to compile my_file.C using the options -v, -g1, and -DPROG=sub. Following are a few examples of command lines you could use:

CC my_file.C -v -g1 -DPROG=sub

CC my_file.C -vg1 -D PROG=sub

CC my_file.C -vg1DPROG=sub

CC -vg1DPROG=sub my_file.C

HP C++ Compiler Options

Table 3-1 “The CC Command Options” lists the options HP C++ supports. Also refer to the HP C++ Online Programmer's Guide for the most detailed and current information.

Table 3-1 The CC Command Options

OptionEffect of Specifying the Option
-Alevel

Allows you to select the mode of preprocessor operation. Level can be either a or c: a requests the ANSI mode HP C++ preprocessor, Cpp.ansi. This is the default. c requests the compatibility mode HP C++ preprocessor, Cpp.

-bCreates a shared library rather than an executable file. The object files must have been created with the +z or +Z option to generate position-independent code (PIC). For more information on shared libraries, see "Creating and Using Shared Libraries" in this chapter, and the manual HP-UX Linker and Libraries Online User Guide.
-cCompiles one or more source files but does not enter the linking phase. The compiler produces an object file (a file ending with .o) for each source file (a file ending with .c, .C, .s, or .i). Note that you must eventually link object files before they can be executed.
-CPrevents the preprocessor from stripping comments from your source file; comments are retained. Refer to the description of Cpp in the HP-UX Reference Manual for details.
-Dname=def-DnameDefines name to the preprocessor Cpp, as if defined by the preprocessing directive #define. If no =def is given, the name is defined as "1". Refer to the Cpp description in the HP-UX Reference Manual for details.
-depth

Instructs the runtime system to traverse the shared library list in a depth-first manner when calling static constructors. The default is to traverse the shared libraries in a left-to-right order when calling static constructors. Use -depth when linking your program with the CC command. The order of execution of static constructors within each shared library is not affected by this option. The routine to load a shared library, cxxsh_load(), also traverses dependent libraries in depth-first order when the program is linked with -depth. For example:

CC -depth prog.C lib1.sl lib2.sl lib3.sl

compiles prog.C, links to the shared libraries lib1.sl, lib2.sl, and lib3.sl, and instructs the runtime startup code to execute the static constructors in lib3.sl first, lib2.sl next, and lib1.sl last. (The default order would be lib1.sl, then lib2.sl, then lib3.sl.)

-ERuns preprocessor only on the named HP C++ or assembly programs and sends the result to standard output (stdout). See also the -.suffix option.
-FRuns only Cpp and the HP C++ translator (see the +T option) on the C++ source files and sends the resulting C source code to standard output (stdout). See also the -.suffix option.
-FcSame as the -F option, but the output is C source code suitable to be redirected to a .c file that can later be compiled using cc. This option is equivalent to using the -F and the +L options together. See also the -.suffix option.
-.suffixCauses the HP C++ translator to direct output from either the -E, -F, or -Fc option into a file with the corresponding .suffix instead of into a corresponding .c file. Note that .suffix may not be the same as the original source file .suffix.
-g

Causes the compiler to generate additional information needed by the symbolic debugger. Note, for 10.x and later releases you can use this option for limited debugging of optimized code with the HP/DDE debugger. To suppress expansion of inline functions use the +d option. See also the -g1 option. For more information about HP Symbolic Debugger, see the HP-UX Symbolic Debugger User's Guide.

-g1

This option is the same as the -g option, except the compiler generates less information about your program for the symbolic debugger, thereby decreasing the size of your object file. Specifically, the -g option emits full debug information about every class referenced in a file, which can result in much redundant information. The -g1 option, on the other hand, emits only a subset of this debug information. If you compile your entire application with -g1 no debugger functionality is lost. Use -g1 when

  • You are compiling your entire application with debug on and your application is large, for example, greater than 1 megabyte.

Use -g when either of the following is true:

  • You are compiling only a portion of your application with debug on.

  • You are compiling you entire application with debug on and your application is not very large, for example, less than 1 megabyte.

If you compile part of an application with -g1 and part with debug off, the resulting executable may not contain complete debug information. You will still be able to run the executable, but in the debugger some classes may appear to have no members. For more information about HP Symbolic Debugger, see the HP-UX Symbolic Debugger User's Guide.

-GPrepares the object file for profiling with gprof++. Refer to the online man page of gprof++ and to the gprof description in the HP-UX Reference Manual for details.
-Idir

Adds dir to the directories to be searched for #include files by the preprocessor. For #include files that are enclosed in double quotes (" ") and do not begin with a /, the preprocessor first searches the directory of the file containing the #include, then the directory named in the -I option, and finally the standard include directories /usr/include/CC and /usr/include. For #include files that are enclosed in angle brackets (< >), the search path begins with the directory named in the -I option and is completed in the standard include directories /usr/include/CC and /usr/include. The current directory is not searched.

-lx

Causes the linker to search the libraries /lib/libx.sl or /lib/libx.a, then /usr/lib/libx.sl or /usr/lib/libx.a (just /usr/lib/libx.sl or /usr/lib/libx.a for Versions 10.x and later) in an attempt to resolve unresolved external references. The -a linker option determines whether the archive (.a) or shared (.sl) version of a library is searched. The linker searches the shared version of a library by default. 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. Refer to the description of ld in the HP-UX Reference Manual for details.

-LdirCauses the linker to search for libraries in the directory dir before using the default search path. This option is passed directly to the linker. The -L option must precede any -lx option entry on the command line; otherwise -L is ignored.
-nCauses the program file produced by the linker to be marked as sharable. For details and system defaults, refer to the description of ld in the HP-UX Reference Manual.
-NCauses the program file produced by the linker to be marked as unsharable. For details and system defaults, refer to the ld description in the HP-UX Reference Manual.
-ooutfileCauses the output of the compilation sequence to be placed in outfile. Without this option the default name is a.out. When compiling a single source file with the -c option, you may use the -o option to specify the name and location of the object file.
-OInvokes the optimizer to perform level 2 optimizations. You can set other optimization levels by using the +O option. Refer to Chapter 4 “Optimizing HP C++ Programs”, "Optimizing HP C++ Programs", for more information about optimization.
-PPreprocess only on files named on the command line without invoking further phases, leaving the result in the corresponding files with the suffix .i.
-pta Instantiates an entire template, rather than only those members that are needed. For more information, see the "Template Instantiation User Guide" in the C++ Language System Selected Readings.
-ptb

Direct the template instantiation system to invoke ld instead of nm to do simulated linking. Using this option may slow the instantiation process considerably. You must use this option when building shared libraries that depend on other shared libraries that contain templates. It can be used for any case.

-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 Performs template instantiation at link time rather than at compile time. This option only affects programs consisting of one file, which have instantiation performed at compile time by default. Instantiation is done at link time for programs consisting of multiple files. For more information, see the "Template Instantiation User Guide" in the C++ Language System Selected Readings.
-ptrpathname Specifies a repository to hold information about your templates. The information in the repository is used whenever a template is instantiated. The default repository is ./ptrepository. If several repositories are given, only the first is writable. For more information, see the "Template Instantiation User Guide" in the C++ Language System Selected Readings.
-pts Causes instantiations to be split into separate object files, with one function per object file. Also causes all class static data and virtual functions to be grouped into a single object file. For more information, see the "Template Instantiation User Guide" in the C++ Language System Selected Readings.
-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 Gives verbose progress reports on the instantiation process. This option is useful for understanding how templates are instantiated. For more information, see the "Template Instantiation User Guide" in the C++ Language System Selected Readings.
-qCauses the output file from the linker to be marked as demand-loadable. For details and system defaults, see the description of ld in the HP-UX Reference Manual.
-QCauses the program file from the linker to be marked as demand-loadable. For details and system defaults, see the description of ld in the HP-UX Reference Manual.
-sCauses the executable program file created by the linker to be stripped of symbol table information. Specifying this option prevents using a symbolic debugger on the resulting program. Refer to the description of ld in the HP-UX Reference Manual for more details.
-SCompiles the named HP C++ program and leaves the assembly language output in a corresponding file with an .s suffix.
-tx, name

Substitutes or inserts subprocess x using name, where x is one or more identifiers indicating the subprocess or subprocesses. 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 value of x can be one or more of the following:

Value

Description

a

Assembler (standard suffix is as).

b

The C compiler driver (cc) used to compile the translated C++ code and invoke the assembler and the linker.

c

The C compiler (translator mode only; standard suffix is ccom.)

C

C++ compiler (standard suffix is cfront).

f

Filter tool (c++filt).

l

Linker (standard suffix is ld).

m

Merge tool (c++merge; translator mode only).

0 (zero)

Same as c. See also Table 3-2.

p

Preprocessor (standard suffix is Cpp).

P

Patch tool (c++patch).

x

All subprocesses.

-UnameRemoves (undefines) any initial definition of name in the preprocessor. Refer to the Cpp description in the HP-UX Reference Manual for details.
-vEnables the verbose mode, sending a step-by-step description of the compilation process to stderr. This is especially useful for debugging or for learning the appropriate commands for processing a C++ file.
-wSuppresses warning messages.
-Wx,arg1[,arg2,..,argn]Passes the arguments arg1 through argn to the subprocess x of the compilation; x can be one of the values described under the -tx, name option with the addition of d, to pass an option to the CC command.
-Y

Enables Native Language Support (NLS) of 8-bit and 16-bit, (also 4-byte EUC for HP-UX 10.x C++ versions)characters in comments, string literals, and character constants. Refer to hpnls, lang, and environ in the HP-UX Reference Manual for a description of the NLS model. The language value (refer to environ for the LANG environment variable) is used to initialize the correct tables for interpreting comments, string literals, and character constants. The language value is also used to build the path name to the proper message catalog.

-y Enable the storage of static analysis information in the generated object files. This information can be used by the static analysis tool which is part of the HP SoftBench software development environment.
-ZAllows dereferencing of null pointers at run time. The value returned from a dereferenced null pointer is zero.
-zDisallows dereferencing of null pointers at run time. Fatal errors result if null pointers are dereferenced.
+a{0|1}

Specifies which style of declarations to produce. In translator mode, the compiler can generate either ANSI C or "Classic C" (also known as K&R C, for Kernighan and Ritchie, authors of a book on the C language) style declarations. The +a0 option, the default, causes the translator to produce "Classic C" style declarations. The +a1 option causes the translator to produce ANSI C style declarations. When you use the +a0 option in compiler mode, value parameters of type float are promoted to type double. When you use +a1, float parameters are not promoted, but are passed as type float. This maintains compatibility with translator mode.

+dPrevents the expansion of inline functions. This option is useful when you are debugging your code because you cannot set breakpoints at inline functions. This option defeats inlining thereby allowing you to set breakpoints at functions specified as inline.
+DAarchitecture

Generates object code for a particular version of the PA-RISC architecture. Also specifies which version of the HP-UX math library to link in when you have specified -lm (-lm or -lM for HP-UX 9.x only). See the HP-UX Floating-Point Guide for more information about using math libraries. architecture can be either a model number of an HP 9000 system (such as 730 or 877), or one of the PA-RISC architecture designations 1.0, 1.1, or 2.0 (2.0 is available for versions 10.22 and later). For example, specifying +DA1.1 or +DA867 generates code for the PA-RISC 1.1 architecture. See the file /usr/lib/sched.models for model numbers and their architectures. (Refer to the file /opt/langtools/lib/sched.models for Versions A.10.01 and later.) Use the command uname -m to determine the model number of your system. Object code generated for PA-RISC 1.1 will not execute on PA-RISC 1.0 systems. For versions 10.22 and later note that object code generated for PA-RISC 2.0 will not execute on PA-RISC 1.1 systems: To generate code compatible across PA-RISC 1.1 and 2.0 workstations and servers, use the +DAportable option. If you are using version A.10.22 or later, do not use the +DA1.0 option. For best performance use +DA with the model number or architecture where you plan to execute the program. Beginning with the HP-UX 10.20 release, the default object code generated by HP compilers is determined automatically as that of the machine on which you compile. (Previously, the default code generation was PA-RISC 1.0 on all Series 800 servers and PA-RISC 1.1 on Series 700 workstations.)

+DSmodel

Performs instruction scheduling tuned for a particular implementation of the PA-RISC architecture. model can be either a model number of an HP 9000 system (such as 730 or 877), or one of the PA-RISC implementation designations 1.0, 1.1. or 2.0 (2.0 is available for versions 10.22 and later)For example, specifying +DS720 performs instruction scheduling tuned for one implementation of PA-RISC 1.1. Specifying +DS745 performs instruction scheduling for another implementation of PA-RISC 1.1. Specifying +DS1.0, +DS1.1, or +DS2.0 performs scheduling for a representative PA-RISC 1.0, 1.1, or 2.0 system, respectively. To improve performance on a particular model of the HP 9000, use +DS with that model number. See the file /usr/lib/sched.models for model numbers and their architectures. (Refer to the file /opt/langtools/lib/sched.models for Versions A.10.01 and later.) Use the command uname -m to determine the model number of your system. Object code with scheduling tuned for a particular model will execute on other HP 9000 systems, although possibly less efficiently. If you do not specify this option, the default instruction scheduling is for the system you are compiling on.

+[no]dup_ static_ removal

(Versions 10.22 and later.) Removes duplicate inline member functions that were dropped out of line because they were too complex or too large. The removal will reduce the size of executables and enhance performance. The default, +nodup_static_removal, does not remove duplicate static member functions. Note: Use of the option +dup_static_removal may give you the linker error: Common block requests for functionname have different lengths. You will get this error in one of two cases. One, your code violates the C++ requirement that "all inline member functions with the same name must also have the same body." Two, you use different compiler options to compile the duplicate inline member functions of different compilation units. Library providers who ship header files may not want to use +dup_static_removal because they may not know if their users compile with the same options as they do. For example:

CC +dup_static_removal prog.C

removes duplicate static member functions.

+e{0|1}

Optimizes a program to use less space by ensuring that only one virtual table is generated per class. The +e0 option causes virtual tables to be external and defined elsewhere, that is, uninitialized. The +e1 option causes virtual tables to be declared externally and defined in this module, that is initialized. When neither option is used, virtual tables are static, that is, there is 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 these class definitions. Refer to the note on the next page for more information.

+eh Enables exception handling. To use exception handling, you must use this option on all of the files in your program. If some files have been compiled with this option and some have not, when you link with the CC command, c++patch will give an error and the files will not link.
+ESfic

(Versions 10.22 and later) Replaces millicode calls with inline fast indirect calls. The +ESfic compiler option affects how function pointers are dereferenced in generated code. The default is to generate low-level millicode calls for function pointer calls. The +ESfic option generates code that calls function pointers directly, by branching through them. Note: The +ESfic option should only be used in an environment where there are no dependencies on shared libraries. The application must be linked with archive libraries only. Using this option can improve run-time performance.

+help

(Versions 10.22 and later) Invokes the initial menu window of the HP C++ Online Programmer's Guide. If +help is used on any command line, the compiler invokes the online reference and then processes any other arguments. If $DISPLAY is set, +help invokes the helpview command. If the display variable is not set, a message so indicates. For example:

CC +help

invokes the online programmer's guide.

+I

Instructs the compiler to instrument the object code for collecting run-time profile data. The profiling information can then be used by the linker to perform profile-based optimization. Code generation and optimization phases are delayed until link time by this option. After compiling and linking with +I, run the resultant program using representative input data to collect execution profile data. Finally, relink with the +P option to perform profile-based optimization. Profile data is stored in flow.data by default. See the +dfname option for information on controlling the name and location of this data file. This option is incompatible with +eh, -g, -g1, -G, +P, -s, -S, and -y. For example:

CC +I -O -c prog.C

CC +I -O -o prog.pbo prog.o

compiles prog.C with optimization, prepares the object code for data collection, and creates the executable file prog.pbo. Running prog.pbo collects run-time information in the file flow.data in preparation for optimization with +P.

+iCauses an intermediate C language source file with the suffix ..c to be produced in the current directory. This option is only valid with the +T option.
+k

(For HP-UX 10.x C++ versions.) By default, the HP C++ compiler generates short-displacement code sequences for programs that reference global data in shared libraries. For nearly all programs this is sufficient. If your program references a large amount of global data in shared libraries, the default code generation for referencing that global data may not be sufficient. If this is the case, when you link your program the linker gives an error message indicating that you need to recompile with the +k option. The +k option generates long-displacement code sequences so a program can reference large amounts of global data in shared libraries. Use +k only when the linker generates a message indicating you need to do so. For example:

 

CC +k prog.C mylib.sl 

Compiles prog.C, generates code for accessing a large number of global data items in the shared library mylib.sl, and links with mylib.sl.

+LGenerates source line number information using the format #line %d instead of #%d. See also the -Fc option.
+mProvides maximum compatibility with the USL C++ implementation. (HP C++ provides optimizations and additional functionality that may not be compatible with other C++ implementations.)
+OoptionsRefer to the HP C++ Online Programmer's Guide for a discussion of all current optimization options.
+pDisallows all anachronistic constructs. Ordinarily, the compiler gives warnings about anachronistic constructs. Using the +p option, the compiler does not compile code containing anachronistic constructs. Refer to The C++ Programming Language for a list of anachronisms.
+RnumAllows only the first numregister variables to actually be promoted to the register class. Use this option when the register allocator issues an "out of general registers" message. (The default value is 10.) This option is only used in translator mode (that is, with the +T option). It is ignored in compiler mode.
+TRequests translator mode. In translator mode your HP C++ source code is translated to C code, then compiled by the HP C compiler, linked and patched.
+wWarns about all questionable constructs, as well as constructs that are almost certainly problems. The HP C++ default is to warn only about constructs that are almost certainly problems. This option also warns you when calls to inline functions cannot be expanded inline.
+xfile This option is only valid in translator mode. This option reads 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 can be useful for cross-compilations and for porting the translator.
+Xd

(Versions 10.22 and later.) Prevents the default elimination of of duplicate symbolic debug information. The compiler now eliminates duplicate symbolic debug information to reduce the size of object files and executables and to enhance performance. To prevent the elimination of duplicate symbolic debug information, use the +Xd option. This option may only be needed if you have pxdb or xdb problems. For example:

CC +Xd prog.C -g

prevents the the elimination of duplicate symbolic debug information.

+Xehdtcount

(Versions A.10.09 and later.) Use +Xehdtcount with the +eh option to generate instrumentation that can locate potential run-time exception handling problems. Use this option when the application exhibits run-time range errors or aborts. You may also use this option during development, in case problems arise.

+z Causes the compiler to generate position-independent code (PIC), necessary for building shared libraries. The options -g, -g1, -G, and -p are ignored if either +z or +Z is used. See also the -b and +Z options. For more information on shared libraries, see "Creating and Using Shared Libraries" in this chapter, and the manual HP-UX Linker and Libraries Online User Guide.
+Z This option is the same as the +z option except it allows for more imported symbols than +z does. In general, use the +z option unless you get a linker error message indicating that you should use +Z.

 

NOTE: The +e0/e1 options were used in earlier versions of cfront to determine when to emit the virtual table for a class. These options are still available but they have no effect in most cases. Currently cfront emits the definitions of the virtual table in the compilation unit that contains the definition (not declaration) of the first function in the class that is virtual and not inline. If there is no such function, multiple virtual tables definitions might still be emitted. For example, if you have a class in which all of the virtual functions are inline, then, by default, cfront emits a virtual table in every compilation unit that uses this class. In such cases, the +e0/+e1 options can be used to control when to emit the virtual function table. In other words, the +e0/+e1 options are useful only when cfront cannot determine a unique place to emit the virtual table. On the HP 9000 Series 700/800, the default is to allow null-pointer dereferencing, so using -Z has no effect.

Unsharable executable files generated with the -N option cannot be executed with exec. For details and system defaults, refer to the description of ld in the HP-UX Reference Manual .

Any other options not recognizable by CC generate a warning to stderr. (Options not recognized by CC are not passed to ld. Use the -Wl, arg option to pass options to ld.)

Environment Variables

This section describes the following environment variables you can use to control the C++ compiler:

  • CXXOPTS

  • TMPDIR

  • CCLIBDIR

  • CCROOTDIR

The CXXOPTS Environment Variable

The compiler divides CXXOPTS options into two sets; those which appear before a vertical bar (|), and those options which appear after the vertical bar. Note that the vertical bar must be delimited by whitespace. The first set of options is placed before the command-line parameters to CC; the second set of options is placed after the command-line parameters to CC. If the vertical bar is not present, all options are placed before the command-line parameters.

NOTE: For C++ versions prior to HP-UX 10.x, the vertical bar is n t supported and all options assigned to the CXXOPTS environment variable are placed before the command-line parameters.

CXXOPTS provides a convenient way to include frequently used command line options automatically. Just set the environment variable with the options you want and the command line options are automatically included each time you execute the CC command.

CAUTION: Using the CCOPTS environment variable in translator mode can cause unexpected side effects because HP C (cc) uses CCOPTS.

For example:

CXXOPTS ="-v | -lm"   sh(1) notation

export CXXOPTS

CC -g prog.C

is equivalent to:

CC -v -g prog.C -lm

The following example:

export CXXOPTS=-v   ksh notation

setenv CXXOPTS -v   csh notation

Causes the option -v to be passed to the CC command each time you execute the CC command.

When CXXOPTS is set as above, the following two commands are equivalent:

CC -g prog.C

CC -v -g prog.C

The TMPDIR Environment Variable

Another environment variable, TMPDIR, allows you to change the location of temporary files that the compiler creates. The directory specified in TMPDIR replaces /tmp and /usr/tmp (/var/tmp for HP-UX 10.x C++ versions) as the default directory for temporary files. The syntax for TMPDIR in csh notation is

setenv TMPDIR altdir

where altdir is the name of the alternative directory for temporary files.

The CCLIBDIR and CCROOTDIR Environment Variables

Two additional environment variables that allow HP C++ to reside in alternate directories are provided. CCLIBDIR causes the CC command to search for libraries in the alternate directory indicated, rather than in their default directories. The CCROOTDIR environment variable causes CC to invoke all subprocesses from an alternate directory indicated, rather than from their default directories.

The syntax in csh notation is:

setenv CCLIBDIR altlibdir

setenv CCROOTDIR altdir

Pragma Directives

This section describes the pragmas you can use within an HP C++ source file. A pragma has effect from the point where it is included to the end of the compilation unit or until another pragma changes its status. For more information about pragmas, see "Pragma Directive" in Chapter 2 “The HP C++ Preprocessor”.

Optimization Pragmas

For information on optimization pragmas, see "Pragma Directives" in the HP C++ Online Programmer's Guide.

Pragmas for Shared Libraries

This section describes a pragma you can use with shared libraries.

Pragma HP_SHLIB_VERSION
#pragma HP_SHLIB_VERSION ["]date["]

With the HP_SHLIB_VERSION pragma you can create different versions of a routine in a shared library. HP_SHLIB_VERSION assigns a version number to a module in a shared library. The version number applies to all global symbols defined in the module's source file.

The date argument is of the form month/year. The month must be 1 through 12, corresponding to January through December. The year can be specified as either the last two digits of the year (92 for 1992) or a full year specification (1992). Two-digit year codes from 00 through 40 represent the years 2000 through 2040.

This pragma should only be used if incompatible changes are made to a source file. If a version number pragma is not present in a source file, the version number of all symbols defined in the object module defaults to 1/90. For more information on shared libraries, see the section "Creating and Using Shared Libraries" later in this chapter. Also see the manual HP-UX Linker and Libraries Online User Guide.

Pragma COPYRIGHT
#pragma COPYRIGHT "string"

COPYRIGHT specifies the name to use in the copyright message, and causes the compiler to put the copyright message in the object file. If no date is specified (using #pragma COPYRIGHT_DATE "string" as shown below), the current year is used.

For example, assuming the year is 1990, the directive #pragma COPYRIGHT "Acme Software" places the following string in the object code:

(C) Copyright Acme Software, 1990. All rights reserved. No part of this program may be photocopied, reproduced, or transmitted without prior written consent of Acme Software.

Pragma COPYRIGHT_DATE
#pragma COPYRIGHT_DATE "string"

COPYRIGHT_DATE specifies a date string to be used in a copyright notice appearing in an object module.

Pragma LOCALITY
#pragma LOCALITY "string"

LOCALITY specifies a name to be associated with the code written to a relocatable object module. All code following the LOCALITY pragma is associated with the name specified in string. The smallest scope of a unique LOCALITY pragma is a function. For example, #pragma locality "mine" builds the name $CODE$MINE$.

Code that is not headed by a LOCALITY pragma is associated with the name $CODE$.

Pragma VERSIONID
#pragma VERSIONID "string"

This pragma specifies a version string to be associated with a particular piece of code. The string is placed into the object file produced when the code is compiled.

© Hewlett-Packard Development Company, L.P.