NOTE: See the Optimizing HP C Programs section of the HP C Online help for a more detailed description of HP compiler optimization options. See the, Parallel Options & Pragmas section of HP C Online Help for detailed description of options and pragmas for threads and parallel programming.
Compiling for Different Versions of the PA-RISC
Architecture
Pragmas
Gather/Scatter Prefetch
Running HP C Programs
cc [options] files
where:
Files with names ending in .i are assumed to be preprocessor output files (see the -P compiler option in Table 5: HP C Compiler Option Details in This section). Files ending in .i are processed the same as .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 included in the linking. All other files are passed directly
to the linker by the compiler.
-optionname [optionarg]where:
cc demo.cthe executable file is named a.out.
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 name my_executable. Then you would use the following command line:
cc -o my_executable my_source.c
For example, suppose you want to compile my_file.c using the -v, -g, and -DPROG=sub compiler options. There are several ways to do this:
cc my_file.c -v -g -DPROG=sub cc my_file.c -vg -D PROG=sub
cc my_file.c -vgDPROG=sub cc -vgDPROG=sub my_file.c
| Trigraph Sequence | Replacement |
|---|---|
| ??= | |
| ??/ | \ |
| ??" | ^ |
| ??( | [ |
| ??) | ] |
| ??! | | |
| ??< | { |
| ??> | } |
| ??- | ~ |
Any ? that does not begin one of the trigraphs listed above is not changed.
Table 6: HP C Compiler Option Details describes
in detail the options that HP C workstations and servers support.
| Option | What It Does | |
|---|---|---|
| -Aa | Requests a compilation in ANSI C mode. The -Aa option requests
a strict implementation of ANSI C. ANSI C specifies which names are available
in the standard libraries and headers, which are reserved for the implementation,
and which must be left available for you. HP C in ANSI mode conforms to
these restrictions and only names permitted by ANSI C are defined or declared
in the standard libraries and headers. Macro definitions can be used to
access names that are normally defined in other standards (POSIX and XOPEN,
for example), and in HP C Version 3.1 compatibility mode. To gain access
to all variables and functions defined by POSIX, include the following
line at the start of your source file before including any system headers:
#define _POSIX_SOURCEor define this macro by using the -D name option: cc -D _POSIX_SOURCE myfile.cTo gain access to all the names defined by XOPEN, include the following line at the start of your source file before including any system headers: #define _XOPEN_SOURCEor define the macro on the command line: cc -D _XOPEN_SOURCE myfile.cTo gain access to all the names normally available in compatibility mode, include the following line at the start of your source file before including any system headers: #define _HPUX_SOURCEor define the macro on the command line: cc -D _HPUX_SOURCE myfile.c_HPUX_SOURCE defines a superset of names defined by _XOPEN_SOURCE. _XOPEN_SOURCE defines a superset of names defined by _POSIX_SOURCE. |
|
| -Ac | Requests compatibility with version 3.1. This was the default at the HP-UX 10.20 operating system release. It is a non-ANSI implementation. | |
| -Ae | Requests a compilation in ANSI C mode with HP C extensions. This option is the same as specifying -Aa, -D_HPUX_SOURCE, and +e. This is the default for the HP-UX 10.30 and later operating system releases. | |
| -Bextern | Performs the same operation as +Oextern=sym1,sym2,sym3...
except that symbols are loaded from an existing file, instead of specified
on the command line. -Bextern does not require that you manually
specify symbols locally, on the command line. In fact, if you specify a
locally-defined symbol with -Bextern, you may experience problems.
When used, -Bextern tells the compiler that the symbols reside in a separate load module. -Bextern:filename fetches the list of symbols from a text file instead of locally. Symbols referenced in the file must be separated by white space within the file. |
|
| -Bhidden | Hides all the symbols including references except for those prefixed with __declspec(dllexport), __declspec(dllimport) or specified with +Oextern or HP_DEFINED_EXTERNAL pragma. This will hide both definitions and references. | |
| -Bhidden_def | Hides all the symbols defined in the module except for those prefixed with __declspec(dllexport). This will hide only definitions. | |
| -c | Compiles one or more source files but does not enter the linking phase. The compiler produces the object file (a file ending with .o by default) for each source file (a file ending with .c, .s, or .i). Object files must be linked before they can be executed. | |
| -C | Prevents the preprocessor from stripping comments. See the description of cpp(1) in the HP-UX Reference Manual for details. | |
| -Dname -Dname=def | Defines name to the preprocessor cpp as if defined by the preprocessing directive #define. If =def is not given, name is "1". Macros should be assigned integer values when they will be used in constant expressions that are to be evaluated by the conditional compilation directives #if and #else. See Conditional Compilation (#if, #ifdef,..#endif) for more information. | |
| -dynamic | This option produces dynamically bound executables. These support shared libraries and use the features of the dynamic loader. The shl_load and dlopen APIs are fully supported. The linker links in shared libraries first and then archive libraries. Only PIC is supported. | |
| -E | Runs the preprocessor only on the named HP C or assembly programs and sends the result to standard output (stdout). | |
| -fast | The -fast compiler option expands into an existing set of
compiler options which, used together, result in optimum speed and application
run-times. This option is also provided for compatibility in porting Sun-
and SGI-compiled applications to HP-UX.
NOTE: Do not use this option for programs that depend on IEEE
standard floating-point denormalized numbers. Otherwise, different numerical
results may occur.
+O3 +nolooptransform +Olibcalls +FPD +Oentrysched +Ofastaccess
|
|
| -g | Inserts information for the symbolic debugger in the object file. In
conjunction with the HP Distributed Debugging Environment (DDE), the C
compiler now provides support for debugging optimized code. This support
includes:
|
|
| -G | Prepares the object file for profiling with gprof. See the gprof(1) description in the HP-UX Reference Manual for details. | |
| -Idir | Adds dir to the list of directories that are 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 current directory, then the directory named in the -I option, and finally, the standard include directory /usr/include. For include files that are enclosed in < and > symbols, the search path begins with the directory named in the -I option and is completed in the standard include directory, /usr/include. The current directory is not searched. | |
| -include <file> |
This option causes the compiler to insert <file> at
the beginning of a set of translation units before processing
them.
Effectively, it executes implicit #include "<file>"
directives for each -include <file> option on the
command line, before the very first line of each of the source files
specified on the command line.
This is a GCC compatibility feature.
Example Usage:
All the |
|
| -lx | Causes the linker to search the libraries /usr/lib/libx.a or /usr/lib/libx.sl (searched first) and /opt/langtools/lib/libx.a or /opt/langtools/lib/libx.sl (searched second). 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. Libraries are searched when their names are encountered. Therefore 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 the description of ld(1) in the HP-UX Reference Manual for details. | |
| -Ldir | Causes the linker to search for libraries in the directory dir
before using the default search path. The default search path is the directory
/usr/lib
followed by /opt/langtools/lib.
-Ldir must precede
-lx
on the command line; otherwise -Ldir is ignored. This option
is passed directly to the linker. For example:
cc -L/project/libs prog.c -lfoo -lbarCompiles and links prog.c and directs the linker to search the directories /project/libs, /usr/lib, then /opt/langtools/lib for libfoo.a, libfoo.sl, libbar.a, and libbar.sl libraries. |
|
| -n | Causes the program file produced by the linker to be marked as shareable. For details and system defaults see the description of ld(1) in the HP-UX Reference Manual. | |
| -N | Causes the program file produced by the linker to be marked as unshareable. For details and system defaults see the ld(1) description in the HP-UX Reference Manual. | |
| -noshared | Creates statically bound executables. This option is available with option +DA2.0W only. See -dynamic for dynamically bound executables. The default behavior is dynamic. | |
| -o outfile | Causes the output of the compilation sequence to be placed in outfile. The default name is a.out. When compiling a single source file with the -c option, you can also use the -o option to specify the name and location of the object file. | |
| -O | Invokes the optimizer to perform level 2 optimization. Other optimization levels can be set. Refer to the HP C/HP-UX Programmer's Guide for details on optimization. | |
| -p | Causes the compiler to produce extra profiling code that counts the number of times each routine is called. Also, if link editing takes place, this option replaces the standard startup routine with a routine that calls monitor(3C) at the start and writes out a mon.out file upon normal termination of the object program's execution. An execution profile can then be generated using prof(1). | |
| -P | Preprocesses only. Runs the preprocessor with the -P option only on the named HP C source files and leaves the result in the corresponding files with .i as the suffix. | |
| -q | Causes the output file from the linker to be marked as demand loadable. For details and system defaults, see the ld(1) description in the HP-UX Reference Manual. | |
| -Q | Causes the program file created by the linker to be marked as not demand loadable. For details and system defaults, see the ld(1) description in the HP-UX Reference Manual. | |
| -s | Strips the executable. Causes the 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. See the ld(1) description in the HP-UX Reference Manual for more details. | |
| -S | Compiles the named HP C program and leaves the assembly language output in a corresponding file with .s as the suffix. | |
| -t x,name | Substitutes or inserts subprocess x with name, where
x
is one or more of a set of identifiers indicating the subprocesses. This
option works in two modes: 1) if x is a single identifier,
name
represents the full pathname 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 pathnames of the new subprocesses.
x
can be one or more of the following values:
|
|
| -Uname | Undefines or removes any initial definition of name in the preprocessor. See the cpp(1) description in the HP-UX Reference Manual for details. | |
| -v | Enables the verbose mode sending a step-by-step description of the compilation process to standard error (stderr.) | |
| -V | Prints version information on each invoked subprocess to standard error (stderr.) | |
| -w | Suppresses 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 -t option with the addition of d, to pass an option to the cc driver. These options are HP value added extensions to HP C. | |
| -W c,-e or +e | Enables the following HP value added features while compiling in ANSI C mode: sized enum, long long, long pointers, compiler supplied defaults for missing arguments to intrinsic calls, and $ in identifier HP C extensions. | |
| -W c,-L or +L | Enables any #pragma listing directives and the listing facility.
A straight listing prints the following:
|
|
| -W c,-m or +m | Causes 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. | |
| -W c,-o or +o | Causes the code offsets to be printed in hexadecimal grouped by function at the end of the listing. | |
| -W c, or -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. | |
| -W c,-wn or +wn | Specifies the level of the warnings messages. The value of n
can be one of the following:
|
|
| -W d,-a | When processing files written in assembly language, this option specifies that the compiler should not assemble with the prefix file that sets up the space and subspace structure required by the linker. Programs assembled with this option may not link unless they contain the equivalent information. You can then optimize the program based on this profile data by re-linking with the +P command line option. The +I command line option is incompatible with the -g, -p, -s, -S, and -y options. The +I option does not affect the default optimization level or the optimization level specified by the -O or +O options. For more details on invoking profile-based optimization, refer to the HP C/HP-UX Programmer's Guide. | |
| -y | Requests the compiler to generate additional information for the static analysis tool, which is a part of the HP SoftBench software development environment. See HP Softbench Static Analyzer: Analyzing Program Structure for more information. | |
| -Y | Enables Native Language Support (NLS) of 8-bit and 16-bit characters in comments, string literals, and character constants. See hpnls(5), long(5), and environ(5) in the HP-UX Reference Manual for a description of the NLS model. The language value is used to initialize the correct tables for interpreting comments, string literals, and character constants. It is also used to build the pathname to the proper message catalog. | |
| -z | Disallows run-time dereferencing of null pointers. Fatal errors result if null pointers are dereferenced. | |
| -Z | Allows dereferencing of null pointers at run-time. (This behavior is the default.) The value of a dereferenced null pointer is zero. | |
| +DAmodel | Generates object code for a particular version of the PA-RISC architecture.
If you do not specify this option, the default object code generated
is determined automatically as that of the system on which you compile.
+DA
also specifies which version of the HP-UX math library to link in when
you specify -lm. (See the HP-UX Floating-Point Guide for
more information about using math libraries.) model can be a model
number of an HP 9000 system (such as, 730, 877, H50, or I50), one of the
PA-RISC architecture designations 1.1,
2.0,
2.0W,
or portable. For example, specifying +DA1.1 or +DA735
generates code for the PA-RISC 1.1 architecture. Similarly, specifying
+DA2.0
generates 32-bit code for the PA-RISC 2.0 architecture. Specifying +DA2.0W
generates 64-bit ELF object files for the PA-RISC 2.0 architecture. Specifying
+DAportable
generates code compatible across all HP 9000 workstations and servers.
See the file /opt/langtools/lib/sched.models for model numbers
and their architectures. Use the command uname -m to determine
the model number of your system.
Note: Object code generated for PA-RISC 2.0 will not execute on PA-RISC 1.1 systems. Object code generated for the 64-bit data model (LP64) will not execute under the 32-bit data model (ILP32). To generate code compatible across PA-RISC 1.1 and 2.0 workstations and servers, use the +DAportable option. For best performance, use +DA with the model number or architecture where you plan to execute the program. Starting at 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 Series 800 servers, and PA-RISC 1.1 on Series 700 workstations.) For more information on this option, see Using +DA to Generate Code for a Specific Version of PA-RISC . See also the +DD32 and +DD64 options. |
|
| +DCapptype | Generate code for portable or embedded applications (64-bit mode only.) When apptype is hpux, the compiler builds portable applications. This is the default behavior, and is equivalent to using +Oextern. When apptype is emb, the options most commonly used to generate embedded systems code are enabled. Note that code generated with the +DCemb must not be included in a shared library. | |
| +DD32 | Generates 32-bit object code for the PA-RISC 1.1 architecture, which runs on PA1.1 and PA2.0 architectures. This option is the same as the options +DA1.1 and +DAportable. | |
| +DD64 | Generates 64-bit object code for PA2.0 architecture. Causes the macros __LP64__ and _PA_RISC2_0 to be #defined. This is the same as +DA2.0W, but is the recommended option to use when compiling in 64-bit mode on the PA RISC 2.0 architecture because it is forward compatible with future 64-bit architectures. | |
| +dfname | Specifies the path name of the profile database to use with profile-based optimization. This option can be used with the +P command line option. The profile database by default is named flow.data. This file stores profile information for one or more executables. Use +df when the flow.data file has been renamed or is in a different directory than where you are linking. You can also use the FLOW_DATA environment variable to specify a different path and file name for the profile database file. The +dfname command line option takes precedence over the FLOW_DATA environment variable. Note, the +dfname option cannot be used to redirect the instrumentation output (with the +I option). It is only compatible with the +P option. | |
| +DOosname | Sets the target operating system for the compiler. The osname can
be:
+DO can be used at any optimization level. By default, when you compile your application, it is binary compatible across the 11.x release. You only need to specify +DO when you want the latest performance features supported in the OS. Caution: Use of +DO with a non-default osname makes the resulting code binary incompatible with an earlier version of HP-UX. |
|
| +DSmodel | Performs instruction scheduling tuned for a particular implementation of the PA-RISC architecture. model can be a model number of an HP 9000 system (such as 730, 877, H50, or I50); a PA-RISC architecture designation 1.1 or 2.0; or a processor name (such as PA7100LC). For example, specifying +DS720 performs instruction scheduling tuned for one implementation of PA-RISC 1.1. Specifying +DSPA7100LC performs scheduling for a system with a PA7100LC processor. Specifying +DSPA8000 performs instruction scheduling for systems based on the PA-RISC 8000 processor. To obtain the best performance on a particular model or processor of the HP 9000, use +DS with that model number or processor name. If you plan to run your program on both PA-RISC 1.1 and 2.0 systems, in general we recommend you use +DS2.0. See the file /opt/langtools/lib/sched.models for model numbers and the processor names for which implementation-specific scheduling is performed. Use the command uname -m to determine the model number of your system. Object code with scheduling tuned for a particular model or processor will execute on other HP 9000 systems, although possibly less efficiently. For more information on this option, see Using +DS to Specify Instruction Scheduling . | |
| +e | See -W c,-e | |
| +ESfic | The +ESfic option generates code for fast indirect calls. This option should only be used in an environment where there are no dependencies on shared libraries. The application must be linked with archive libraries. Using this option can improve run-time performance. | |
| +ESconstlit | Introduces a new default behavior for the HP C compiler, in which HP C stores constant-qualified (const) objects and literals in read-only memory. Storing const-qualified string literals in read-only memory can cause a program which violates the semantics of const to abnormally terminate with a bus error and core dump. This is because literals, which have been placed in read-only memory, may not be modified at runtime. See the description of +ESnolit for details on how to specify that literals not be placed in read-only memory. | |
| +ESlit | Places string literals and constants defined with the ANSI C const
type qualifier into the $LIT$ subspace. The $LIT$ subspace
is used for read-only data storage. This option can reduce memory requirements
and improve run-time speed in multi-user applications. Normally the C compiler
only places floating-point constant values in the $LIT$ subspace,
and other constants and literals in the $DATA$ subspace. This
option allows the placement of large data objects, such as ANSI C const
arrays, into the $LIT$ subspace. All users of an application share
the static data stored in the $LIT$ subspace. Each user is allocated
a private copy of the dynamic data stored in the $DATA$ subspace.
By moving additional static data from the $DATA$ subspace to the
$LIT$
subspace, overall system memory requirements can be reduced and run-time
speed improved. Most applications can benefit from this option. Users should
not attempt to modify string literals if they use the +ESlit option.
The reason is that this option places all string literals into read-only
memory. Particularly, the following C library functions should be used
with care, since they can alter the contents of string literals if users
specify string literals as the receiving string.
extern char *strncat(char *, const char *, size_t); extern void *memmove(void *, const void *, size_t); extern char *strcpy(char *, const char *); extern char *strncpy(char *, const char *, size_t); extern char *strcat(char *, const char *); extern char *strtok(char *, const char *); |
|
| +ESloc=name | This option will create a subspace by this name and will put all data and code in the relocatable object module by this name. | |
| +ESnolit | +ESnolit disables the default behavior of the HP C compiler to store literals in read-only memory. Specifying this option causes HP C to no longer store literals in read-only memory. This restores HP C's traditional behavior prior to this release of the compiler. | |
| +ESnoparmreloc | +ESnoparmreloc disables parameter relocation for function
calls. If your source code uses the ANSI C function prototype consistently
in both declaration and definition of a function, this option may allow
you to produce smaller and faster function entry code. The library is compiled
with this option off. So, to use this option in your code, you must declare
the library functions without function prototype. For example, cos
has not been compiled with +ESnoparmreloc. If you declare cos
with a function prototype as shown below, and compile with +ESnoparmreloc,
an incorrect value will be passed to cos().
double cos(double);
main()
{
printf("%f\n", cos(1.0));
}
For more information on parameter relocation, see the HP PA-RISC Procedure
Calling Conventions Reference Manual, HP part number 09740-90015. |
|
| +ESsfc | Replaces millicode calls with inline code when performing simple function pointer comparisons. The +ESsfc compiler option affects how function pointers are compared in generated code. The default is to generate low-level millicode calls for function pointer comparisons. The +ESsfc option generates code that compares function pointers directly, as if they were simple integers. The +ESsfc option should only be used in an environment where there are no dependencies on shared libraries. The application must be linked with archive libraries. Using this option can improve run-time performance. | |
| +f | Inhibits the automatic promotion of float to double when evaluating expressions. This differs from the +r option in that both parameters and function return values are still promoted to double. In ANSI mode, this option is ignored and a warning is issued. | |
| +FPflags | Specifies what floating-point traps to enable and also enables or disables
fast underflow mode. flags is a series of upper case or lower case
letters from the set [VvZzOoUuIiDd] with no spaces, tabs, or other
characters between them. If the upper-case letter is selected, that behavior
is enabled. If the lower-case letter is selected or if the letter is not
present in the flags, the behavior is disabled. By default, all traps are
disabled. The values for flags are:
|
|
|
||
| +help | Launches a web browser displaying an html version of the HP C/HP-UX online help, and then processes any other arguments. | |
| +hugesize=n[M][K] | Lowers the threshold for huge data.
The compiler puts all small arrays, structures, and unions into a separate subspace. An application with too many arrays may run out of subspace creating an overflow condition. In this case linking fails. One way to solve this problem is to lower the threshold so that any array greater than or equal to the threshold (in bytes) is put into the huge data subspace instead. The following example lowers the threshold to 223 (8 megabytes) resulting in more data objects being put in huge subspace: cc +DD64 +hugesize=8M app1.c app2.cFor more information, see cc +help. |
|
| +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. 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. | |
| +k | Generates long-displacement code sequences so a program can reference large amounts of global data that is physically located in shared libraries. Only use +k when you get a linker message indicating you need to use it. By default, the HP C compiler generates short-displacement code sequences for programs that reference global data that is physically located 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 will give an error message indicating that you need to recompile your program with the +k option. | |
| +L | See -W c,-L | |
| +m | See -W c,-m | |
| +M0 (or +M) | Emits ANSI C migration warnings. Use the +M option with either -Aa or -Ac. These were formerly part of +w1. The document ANSI Programming Language C Standard ISO 9899:1990 discusses the behavioral differences in code that is migrated to ANSI C. These differences are called quiet changes. | |
| +M1 | Emit warnings for possible problems connected with platform migration. | |
| +M2 | Emit warnings for possible problems connected with migration to the LP64 data model (64-bit mode). This option is only available in 64-bit mode. Refer to the HP-UX 64-bit Porting and Transition Guide for details. | |
| +o | See -W c,-o | |
| +[no]objdebug | When used with -g, +objdebug leaves debug information in the object
files instead of copying it to the executable file at link time, resulting
in shorter link times and smaller executables. The default, +noobjdebug,
copies the debug information to the executable file.
When you specify -g, the compiler places symbolic debugging information into the object files. By default, the linker calls pxdb which compacts this debug information & copies it to the executable file. When +objdebug was used at compile time, the linker leaves the debug information in the object files. To debug the executable file, the HP WDB debugger must have access to the object files. If you move the object files, use HP WDB's objdir command to tell it where the object files are. (The HP DDE debugger does not support this option.) This option reduces link time and the size of the executable file by avoiding this copying of debug information. The compile-time default is +noobjdebug. If the linker detects any object files that were compiled with +objdebug, it will leave the debug information in those files. Any object files not compiled with +objdebug will have their debug information copied into the executable file. You can leave debug information in some object files and not in others. Use the +noobjdebug option when linking to explicitly tell the linker to copy all debug information to the executable file, even from files compiled with +objdebug. |
|
| +Oopt | Invokes the level of optimization selected by opt. opt
can have any of the following values.
|
|
| +P | Directs the compiler to use profile information to guide code generation and profile-based optimization. This option causes the compiler to generate intermediate compiler code instead of compiled object code. The actual code generation is done at link time. The +P option does not affect the default optimization level, or the optimization level specified by the -O or +Oopt options. Note: Source files that are compiled with the +I option do not need to be recompiled with +P in order to use profile-based optimization. You only need to relink the object files with the +P option after running the instrumented version of the program. The +P command line option is incompatible with the +I, -g, -s, -S, and -y options. Also refer to the +I, +pgm and +df command line options. For more information on using these options, see the HP C/HP-UX Programmer's Guide. | |
| +pa | Requests that the application be compiled for routine-level profiling with CXperf. The +pa option is not valid with the +O4 or +Oall optimization options. Also, +pa is not compatible with the -p or -G options. For more information, see the CXperf Online Help or CXperf Command Reference. | |
| +pal | Requests that the application be compiled for routine-level and loop-level profiling with CXperf. The +pal option is not valid with the +O4 or +Oall optimization options. Also, +pal is not compatible with the -p or -G options. For more information, see the CXperf Online Help or CXperf Command Reference. | |
| +pgmname | Specifies a program name to look up in the flow.data file. Used with profile-based optimization and the +P option. +pgmname should be used when the name of the profiled executable differs from the name of the current executable specified by the -o option. | |
| +r | Inhibits the automatic promotion of float to double when evaluating expressions and passing arguments. This option is not valid in ANSI mode. | |
| +ub | This option treats unqualified char, short, int, long and long long bitfields as unsigned. This option has no effect on signedness of enum bitfields or on signedness of non-bitfield character | |
| +sb | Use signed bitfields (in 32- and 64-bit modes). By default, unqualified bitfield types are signed in 32-bit mode and unsigned in 64-bit mode. | |
| +ubytes | Forces all pointer references to assume that data is aligned on either an 8-bit, 16-bit, or 32-bit addresses. bytes can be 1 (8-bit), 2 (16-bit), or 4 (32-bit). The default value for +u is 2. This option can be used when reading in non-natively aligned data. Pragmas are also available to assist with processing non-natively aligned data. Refer to Chapter 2, "Storage and Alignment Comparisons," in the HP C/HP-UX Programmer's Guide for detailed information on the HP_ALIGN and PACK pragmas. | |
| +uc | Makes unqualified char data types unsigned. By default, the HP C compiler makes all unqualified char data types signed. Use this option to help port applications from other vendor platforms, where the default behavior for unqualified char types is unsigned. Be careful when using this option. Your application may have trouble interfacing with HP-UX system libraries and other libraries that do not use this option. | |
| +wn | Specifies the level of the warnings messages. The value of n
can be one of the following:
|
|
| +W n1[,n2[,...nN]] | Suppresses the specified warnings, where n1 through nN are valid compiler warning message numbers. See the file /opt/ansic/lib/nls/msg/C/cc.msgs for a list of error and warning messages. | |
| +Wen1[,n2[,...nN]] | Changes the specified warning to an error, where n1 through nN are valid compiler warning messages. See the file /opt/ansic/lib/nls/msg/C/cc.msgs for a list of compiler messages. | |
| +Wwn1[,n2[,...nN]] | Enables the specified warnings, assuming all other warnings have been suppressed with -w or +w3.n1 through nN are valid compiler warning messages. See the file /opt/ansic/lib/nls/msg/C/cc.msgs for a list of compiler messages. | |
| +z | Generates object code that can be added to a shared library. Object code generated with this option is position independent, containing no absolute addresses. All addresses are either pc-relative or indirect references. This is the same as the +Z option in 64-bit mode. The -p and -G options are incompatible with this option and are ignored. See the HP-UX Linker and Libraries Online User Guide for detailed information on shared libraries. | |
| +Z | This option is similar to +z with the difference being that space for more imported symbols is allocated. The size of the data linkage table allocated by the +z and +Z options is machine dependent. Use the +Z option when the linker ld issues an error message indicating data linkage table overflow. +Z is the default in 64-bit mode. For more information on shared libraries, see the HP-UX Linker and Libraries Online User Guide. | |
| Any other option encountered generates a warning to standard error (stderr.) (Options not recognized by cc are not passed on to ld. Use the -Wl,arg option to pass options to ld.) |
The syntax for the CCOPTS environment variable in C shell notation is:
setenv CCOPTS [options] [ | [options]]The compiler places the arguments that appear before the vertical bar in front of the command line arguments to cc. It then places the second group of arguments after any command line arguments to cc.
Options that appear after the vertical bar in the CCOPTS variable override and take precedence over options supplied on the cc command line.
If the vertical bar is omitted, the compiler gets the value of CCOPTS and places its contents before any arguments on the command line.
For example, the following in C shell notation
setenv CCOPTS -v cc -g prog.cis equivalent to
cc -v -g prog.cFor example, the following in C shell notation
setenv CCOPTS "-v | +O1" cc +O2 prog.cis equivalent to
cc -v +O2 prog.c +O1In the above example, level 1 optimization is performed, since the +O1 argument appearing after the vertical bar in CCOPTS takes precedence over the cc command line arguments.
setenv TMPDIR altdir
where altdir is the name of the alternative directory for temporary
files.
-g option. For getting the older behavior
(emitting debug information for all objects, irrespective of whether they are used
in the program or not), an environment variable HPC_DEBUG_COMPAT can be
set in the environment along with the -g option in the compilation commandline. This environment variable does not have to be set to any particular value.
export SDKROOT=/opt/xdk-iawill prefix all references to the HP C compiler tool set components with /opt/xdk-ia. The following details the default tool set components location as specified in the above command and its earlier location before the execution of the command:
| Native location | Alternate tool set location |
| /opt/ansic/bin/cc | /opt/xdk-ia/opt/ansic/bin/cc |
| /opt/ansic/lbin/ccom | /opt/xdk-ia/opt/ansic/lbin/ccom |
| /opt/langtools/lbin/cpp | /opt/xdk-ia/opt/langtools/lbin/cpp |
| /opt/ansic/lbin/ucomp | /opt/xdk-ia/opt/ansic/bin/ucomp |
Invoking the tool set components will actually result in the invocation of tool set components from the alternate location as specified above.
export TARGETROOT=/opt/xdk-iawill prefix all references to the target tool set components with /opt/xdk-ia. The following details the default location of the tool set components as specified in the above command and its earlier location before the execution of the command:
| Native location | Alternate tool set location |
| /usr/include | /opt/xdk-ia/usr/include |
| /use/lib | /opt/xdk-ia/usr/lib |
| NOTE | Options like -l or -L on the command line will override $TARGETROOT prefixing. |
The +DA option specifies which PA-RISC instruction set the compiler should use when generating code. Specifying +DAportable ensures your code will run on HP PA-RISC 2.0 and 1.1 systems, although the performance of your program may not be as good as it could be if optimized for a specific system. Specifying +DA1.1 may give better performance on PA-RISC 1.1 systems, but the executable file generated with this option will not run on PA-RISC 1.0 systems. Specifying +DA2.0 gives optimal performance on PA-RISC 2.0 systems, but the program will not run on the earlier PA-RISC architectures.
Use the command uname -m to determine the model number of your system.
When you use the +DA option depends on your particular circumstance.
Use the +DS option to specify instruction scheduling tuned to a particular implementation of PA-RISC. Note that model can be a model number of an HP 9000 system (such as 730, 877, or H40); a PA-RISC architecture designation 1.1 or 2.0; or one of the PA-RISC processor names (such as PA7000, PA7100, PA7100LC, or PA8000.)
For example, to specify instruction scheduling for the model 867, use +DS867. To specify instruction scheduling for the PA-RISC 7100LC processor, use +DSPA7100LC. To specify instruction scheduling for systems based on the PA-RISC 8000 processor, use +DSPA8000.
If you plan to run your program on both PA-RISC 1.1 and 2.0 systems, in general we recommend you use the +DS2.0 designation.
See the file /opt/langtools/lib/sched.models for model numbers and processor names. Use the command uname -m to determine the model number of your system.
If you do not specify a +DA or +DS option, the default instruction scheduling is based on that of the system on which you compile. If you do specify a +DA option and do not specify a +DS option, the default instruction scheduling is based on what you specify in +DA, and not based on that of the system on which you compile. For example, if you specify +DA1.1 and do not specify +DS, and instruction scheduling will be for 1.1. Specify +DAportable and do not specify +DS, and instruction scheduling will be for 1.1. (+DAportable is currently equivalent to +DA1.1.)
When you use the +DS option depends on your particular circumstance.
HP C provides you the following pragmas:
#pragma INIT "string"Use the compiler pragma INIT to specify an initialization function. The functions take no arguments and return nothing. The function specified by the INIT pragma is called before the program starts or when a shared library is loaded.
For example:
#pragma INIT "my_init"void my_init() { ... do some initializations ... }
#pragma FINI "string"Use the compiler pragma FINI to specify a termination function. The function specified by the FINI pragma is called after the C program terminates by either calling the libc exit() function, returning from the main or _start functions, or when the shared library which contains the FINI is unloaded from memory. Like the function called by the INIT pragma, the termination function takes no arguments and returns nothing.
For example:
#pragma FINI "my_fini"void my_fini() { ... do some clean up ... }
The function returns nothing but takes two arguments. The first is a handle to the shared library being initialized. This handle can be used in calling shl_load API routines. The second is set to non-zero at startup and zero at program termination.
$ ld -b foo.o +I my_10x_init -o libfoo.slfont=*
#include <dl.h>
void my_10x_init(shl_t handle, int loading)
{
/* handle is the shl_load API handle for the shared library being initialized.
/* loading is non-zero at startup and zero at termination.
*/ if (loading)
{
... do some initializations ...
} else
{... do some clean up ...
}
}
This type is only supported when creating a shared library (linker -b
option). Also note that it may not be called when the user's program terminates.
They are always called, however, if the library is explicitly unloaded
as a result of a shl_load or dlopen API call. All three types
(INIT,
FINI, and +I) are supported in 64-bit
links. Only HP-UX 10.x style initializers are supported in 32-bit
links.
#pragma INTRINSIC intrinsic_name1 [user_name] [,intrinsic_name2] [user_name]...Declares an external name as an intrinsic.
#pragma INTRINSIC_FILE "path"Specifies the path of a file in which the compiler can locate information about intrinsic functions.
#pragma COPYRIGHT "string"Places a copyright notice in the object file, using the "string" argument and the date specified using COPYRIGHT_DATE. If no date has been specified using #pragma COPYRIGHT_DATE, 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 "string"Specifies a date string to be used in a copyright notice appearing in an object module.
#pragma LOCALITY "string"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" will build the name "$CODE$MINE$".
Code that is not headed by a LOCALITY pragma is associated
with the name $CODE$. An empty "string" causes the code
name to revert to the default name of $CODE$.
#pragma LOCALITY_ALL "string"The functionality of LOCALITY_ALL pragma is similar to the LOCALITY pragma. In addition to the LOCALITY pragma, LOCALITY_ALL pragma also puts the data along with the code to the relocatable object module as specified in the string.
#pragma VERSIONID "string"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.
#pragma HP_ALIGN align_mode [PUSH] #pragma HP_ALIGN POP
The HP_ALIGN pragma must have a global scope (outside of any function, enclosing structure, or union).
#pragma HP_ALIGN POPThis option to HP_ALIGN restores the previous alignment environment saved using the HP_ALIGN PUSH pragma by deleting the current alignment mode from the top of the stack. If the alignment stack is empty, the default alignment is made the current mode.
#pragma HP_ALIGN align_mode PUSHThis pragma saves the current alignment environment for later retrieval by pushing it into a last in, first out (LIFO) stack. The align_mode is made the new current alignment by placing it on the top of the stack.
#pragma HP_ALIGN HPUX_WORDResults in int and float types being halfword aligned (two-byte aligned), doubles being word aligned (four byte aligned), and all structs being at least halfword aligned. This is the default for the Series 300/400 computer.
#pragma HP_ALIGN HPUX_NATURAL_S500Results in doubles being word aligned. This is the default for the Series 500 computer.
#pragma HP_ALIGN HPUX_NATURALResults in native alignment for the HP 9000 workstations and servers. The int and float types are word aligned, doubles are double-word aligned (8-byte aligned), and structs may be byte aligned depending upon the data types used within the structure.
#pragma HP_ALIGN NATURALResults in a superset of the above. Uses native alignment provided by HPUX_NATURAL, all structs and unions are at least halfword aligned, and DOMAIN bit-field mapping is used. (See Chapter 2, "Storage and Alignment Comparisons," in the HP C/HP-UX Programmer's Guide for details regarding Domain bit-fields.)
#pragma HP_ALIGN DOMAIN_NATURALSimilar to NATURAL except long doubles are only 8 bytes long (treated as doubles).
#pragma HP_ALIGN DOMAIN_WORDSimilar to HPUX_WORD, with the following exceptions: long doubles are only 8 bytes long (treated as doubles) and DOMAIN bit-field mapping is used. Refer to Chapter 2, "Storage and Alignment Comparisons," in the HP C/HP-UX Programmer's Guide for detailed information on Domain bit-fields.
#pragma HP_ALIGN NOPADDINGCauses all structure and union members that are not bit-fields to be packed on a byte boundary. It does not cause crunched data packing, where there are zero bits of padding. It only ensures that there will be no full bytes of padding in the structure or union.
References to non-natively aligned data often results in poorer run-time performance than references to natively aligned data. Natively aligned data is often accessed with a single load or store instruction. Non-natively aligned data must be accessed with one or more load and store instructions.
The HP_ALIGN pragma differs from the +ubytes compiler option. When you use the HP_ALIGN pragma, the compiler localizes inefficient code generation to accesses of data declared with structures or unions under the HP_ALIGN pragma. The +ubytes option assumes that all references to pointer objects are misaligned and performs worst case code generation for all loads and stores of dereferenced data.
The HP_ALIGN pragma offers better run-time performance than the +unumber option. However, the HP_ALIGN pragma requires careful pointer assignment and dereferencing. The following example shows how the pragma is often misused, and what can be done to correct the mistake.
#pragma HP_ALIGN HPUX_WORD
struct {
char chardata;
int intdata;
} stvar;
main()
{
int *localptr;
int localint;
localptr = &stvar.intdata;
localint = *localptr; /* invalid dereference */
}
The above program aborts at run-time when localptr is dereferenced.
The structure stvar is declared under the HP_ALIGN HPUX_WORD
pragma. Its members will not be natively aligned for PA-RISC. The member
stvar.intdata
is aligned on a two byte boundary.
The error occurs after the address of stvar.intdata is assigned to localptr. localptr is not affected by the HP_ALIGN HPUX_WORD pragma. When localptr is used to access the data, it is treated as a pointer to four-byte aligned data rather than as a pointer to two-byte aligned data and a run-time error can occur.
Two solutions help to work around this problem. First, the recommended solution is to access non-natively aligned data through structures or unions that are declared under the HP_ALIGN pragma.
For example, the above program can be transformed to:
#pragma HP_ALIGN HPUX_WORD
struct {
char chardata;
int intdata;
} stvar; /* stvar is declared under the HP_ALIGN pragma */
main()
{
int *localptr;
int localint;
localint = stvar.intdata; /* Valid access of non-naturally */
/* aligned data through a struct */
}
The second method is to inform the compiler that all access of data must
assume potentially non-natural alignment. In the case of #pragma HP_ALIGN
HPUX_WORD shown in the first example above, you can use the +u2
command line option. This causes all loads and stores of any data to be
performed in increments of no greater than 2-bytes at a time.
For complete details about the +ubytes option, see Table
6: HP C Compiler Option Details .
#pragma PACK nThe PACK pragma is a simple, intuitive way for users to specify alignment. In the syntax, n is the byte boundary on which members of structs and unions should be aligned, and can be 1, 2, 4, 8, or 16.
The PACK pragma is not intended to be an "extension" of the HP_ALIGN pragma. It is, instead, a simple and highly portable way of controlling the alignment of aggregates. It has some significant differences with the HP_ALIGN pragma, including uniform bitfield alignment, uniform struct and union alignment, and the lack of PUSH and POP functionality.
For complete details on the use of HP_ALIGN and PACK
pragmas, see Chapter 2, "Storage and Alignment Comparisons," in the HP
C/HP-UX Programmer's Guide.
#pragma HP_OPT_DATA argumentThis pragma is used to explicitly specify memory locations that can be prefetched from memory into the cache. This pragma can take only one address as an argument. The argument should have 'register' storage class.
Example:
register int *pi; #pragma HP_OPT_DATA pi
#pragma LINES linenumSets the number of lines per page to linenum. The default is 63. The minimum number of lines per page is 20.
#pragma WIDTH pagewidthSets the width of the page to pagewidth. The default is 80 columns. The minimum number of columns per page is 50. Place the WIDTH pragma before any TITLE or SUBTITLE pragmas. The width of the title and subtitle fields varies with the page width.
#pragma TITLE "string"Makes string the title of the listing. String can have a length of up to 44 characters less than the page width (additional characters are truncated with no warning). The default is no title.
#pragma SUBTITLE "string"Makes string the subtitle of the listing. String can have a length of up to 44 characters less than the page width (additional characters are truncated with no warning). 8The default is no subtitle.
#pragma PAGECauses a page break and begins a new page.
#pragma LIST { ON }
#pragma LIST { OFF }
Turns listing functionality ON or OFF when used with the -Wc,-L
command line option. The default is ON. Use this pragma to exclude source
lines you do not need to list such as include files.
#pragma AUTOPAGE { ON }
#pragma AUTOPAGE { OFF }
ON causes a page break after each function definition. If the
pragma is declared without specifying either the ON or OFF
option, then page breaks are generated. If the pragma is not used then
no page breaks are generated.
#pragma ALLOCS_NEW_MEMORY functionname1,...,functionnamenStates that the function functionname returns a pointer to new memory that it allocates or a routine that it calls allocates. This pragma provides additional information to the optimizer which results in more efficient code.
#pragma FLOAT_TRAPS_ON { functionname,...functionname }
#pragma FLOAT_TRAPS_ON {_ALL }
Informs the compiler that you may have enabled floating-point trap handling.
When the compiler is so informed, it will not perform loop invariant code
motion (LICM) on floating-point operations in the functions named in the
pragma. This pragma is required for proper code generation when floating-point
traps are enabled and the code is optimized.
The _ALL parameter specifies that loop invariant code motion
should be disabled for all functions within the compilation unit.
#pragma INLINE [functionname1,...,functionnamen] #pragma NOINLINE [functionname1,...,functionnamen]Enables (or disables) inlining of functions. If particular functions are specified with the pragma, they are enabled (or disabled) for inlining. If no functions are specified with the pragmas, all functions are enabled (or disabled) for inlining. Refer to the HP C/HP-UX Programmer's Guide for details and examples.
#pragma PTRS_STRONGLY_TYPED BEGIN #pragma PTRS_STRONGLY_TYPED END #pragma NOPTRS_STRONGLY_TYPED BEGIN #pragma NOPTRS_STRONGLY_TYPED ENDSpecifies when a subset of types are type-safe, providing a finer level of control that +O[no]ptrs_strongly_typed. The pragma will take precedence over the command line option, although sometimes both are required. Refer to the HP C/HP-UX Programmer's Guide for details and examples.
#pragma NO_SIDE_EFFECTS functionname1,...,functionnamenStates that functionname and all the functions that functionname calls will not modify any of a program's local or global variables. This pragma provides additional information to the optimizer which results in more efficient code. See the HP C/HP-UX Programmer's Guide for further information.
#pragma HP_SHLIB_VERSION "mm/[yy]yy"Assigns a version number to a shared library module. This enables you to store multiple versions of a subroutine in a shared library.
The version number is specified by mm/[yy]yy. mm represents the month, and must be from 1 to 12. [yy]yy represents the year, either in 2 digits or 4 digits. If the 2 digit form is used, it must be from 90 to 99, and will be interpreted as 1990 to 1999. The 4 digit form must be from 1990 to 7450.
This pragma provides a way to guard against unexpected side effects when a shared library is updated. You can put multiple versions of a routine in the library and ensure that programs use the correct version. The date in the SHLIB_VERSION pragma provides the version number. Programs call the version in the shared library with a date less than or equal to the date the program was linked.
The version number should only be incremented when changes made to a
subroutine make the new version of the subroutine incompatible with previous
versions.
#pragma HP_DEFINED_EXTERNAL sym1, sym2, ...The externally defined symbol pragma specifies that the designated symbols are imported from another load module (program file or shared library). Note that this pragma currently works in 32-bit mode only. For 64-bit mode, see the option +Oextern.
#pragma HP_LONG_RETURN func1, func2, ...The long return sequence pragma specifies that the named procedures can return directly across a space, without needing to return through an export stub. The main goal of this pragma is to eliminate export stubs, and better enable inlining of import stubs and $$dyncall functionality for indirect calls.
#pragma HP_NO_RELOCATION func1, func2, ...The no parameter/return relocation pragma is used to suppress unnecessary floating point argument relocation. When used, the burden is on the caller and callee to have their argument and their return values agree in which register files they are passed.
#pragma prefetch <argument>The behavior of this pragma is as similar as HP_OPT_DATA pragma which just prefetches the data specified. But the prefetch pragma can access cache lines that are accessed via a vector of indices.
| NOTE | The argument, can have only one argument per pragma and the argument must be an array element (ex: a[i]). |
Compiler generates instructions to prefetch the cache lines starting from the address of the argument. The caveat is that the values prefetched must be valid values. Reading off the end of an array may result in undefined behavior during runtime.
testprefc2(int n, double *a, int *ia, double *b)
{
for (int i=0; i < n; i++) {
b[i] = a[ia[i]];
}
}
Recoding this routine as
#define USER_SPECIFIED 30
testprefc2(int n, double *a, int *ia, double *b)
{
int dist = (int)USER_SPECIFIED;
int nend = max(0,n-dist); /* so as not to read past the end of ia */
for (i = 0; i < nend; i++) /* original loop is for (i = 0; i < n; i++) */
{
#pragma prefetch ia[i+4*dist]
#pragma prefetch a[ia[i+dist]]
b[i] = a[ia[i]];
}
/* finish up last part with no prefetching */
for (int i = nend; i < n; i++)
b[i] = a[ia[i]];
}
allows a[ia[i]] to be prefetched. Note that the compiler
continues to unroll the loops as in the original code.