HP Itanium®-based Systems HP aC++/HP C Programmer's Guide Version A.06.
Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice.
Table of Contents About This Document ..................................................................................................................23 Intended Audience.............................................................................................................23 What’s in This Document....................................................................................................23 Typographical Conventions............................................................................
Floating Installation............................................................................................................37 HP aC++.........................................................................................................................37 HP C..............................................................................................................................38 Setting up Floating Installation....................................................................................
+wsecurity.....................................................................................................................51 Exception Handling............................................................................................................52 +noeh.............................................................................................................................52 Extensions to the Language..............................................................................................
-q....................................................................................................................................65 -Q...................................................................................................................................65 -r....................................................................................................................................65 -s....................................................................................................
+Ofrequently_called.................................................................................................78 +O[no]initcheck........................................................................................................78 +O[no]inline.............................................................................................................78 +Oinlinebudget........................................................................................................79 +Olit.....................
+DSmodel......................................................................................................................94 Porting Options...................................................................................................................94 -fast................................................................................................................................94 +sb...............................................................................................................
-AOa and -AOe............................................................................................................112 -AP...............................................................................................................................112 -Ax...............................................................................................................................112 +legacy_cpp............................................................................................................
INIT..............................................................................................................................127 FINI..............................................................................................................................127 Copyright Notice and Identification Pragmas.................................................................128 COPYRIGHT...............................................................................................................
RARELY_CALLED Pragma.........................................................................................143 STDC CX_LIMITED_RANGE Pragma........................................................................143 STDC FLOAT_CONST_DECIMAL64 Pragma ...........................................................143 STDC FP_CONTRACT Pragma..................................................................................144 STDC FENV_ACCESS Pragma..................................................................
4 Preprocessing Directives..........................................................................................................157 Overview of the Preprocessor...........................................................................................157 Syntax..........................................................................................................................157 Usage Guidelines........................................................................................................
Syntax.....................................................................................................................170 Description.............................................................................................................171 Example..................................................................................................................171 Error Directive (#error)................................................................................................171 Syntax......
explicit Keyword.........................................................................................................185 Usage......................................................................................................................185 Example..................................................................................................................186 mutable Keyword........................................................................................................187 Usage.......
Enabling Aggressive Optimizations......................................................................207 Enabling Only Conservative Optimizations..........................................................207 Removing Compilation Time Limits When Optimizing.......................................207 Limiting the Size of Optimized Code....................................................................208 Combining Optimization Options.........................................................................
_OPENMP Macro...................................................................................................221 Environment Variables in OpenMP............................................................................221 OMP_SCHEDULE..................................................................................................221 OMP_NUM_THREADS.........................................................................................222 OMP_DYNAMIC....................................................
Standard C++ Library Reference............................................................................234 Incompatibilities Between the Library and the Standard......................................234 Tools.h++ Library....................................................................................................234 HP aC++ Runtime Support Library........................................................................235 IOStream Library..............................................................
Data Compatibility between C and C++...........................................................................247 HP aC++ Calling HP C.................................................................................................248 Using the extern "C" Linkage Specification...........................................................248 Syntax of extern "C"................................................................................................248 Examples of extern "C".............................
Differences in setjmp/longjmp Behavior.....................................................................268 Calling unexpected......................................................................................................269 Unreachable catch Clauses..........................................................................................270 Throwing an Object having an Ambiguous Base Class..............................................270 Migration Considerations when Using Libraries..............
Digraph White Space Separators...........................................................................287 Migration Considerations when Using Templates...........................................................288 Verbose Template Processing Information..................................................................288 Common Template Migration Syntax Changes..........................................................288 The cfront Implicit Include Convention..............................................
List of Tables 1 2-1 2-2 2-3 2-4 2-5 2-6 2-7 2-8 6-1 6-2 12-1 12-2 12-3 HP-UX 11i Releases.....................................................................................................25 ILP32 Data Model and LP64 Data Model...................................................................41 Size and Alignment of HP Compiler Data Types.......................................................43 Options for +FP[flags].......................................................................................
About This Document This manual presents programming information on the C++ programming language, as implemented on Itanium®- based systems. The document printing date and part number indicate the document’s current edition. The printing date will change when a new edition is printed. Minor changes may be made at reprint without changing the printing date. The document part number will change when extensive changes are made.
Chapter 5 Using HP aC++ Templates Gives you an overview of template processing and describes the instantiation coding methods available in HP aC++. Chapter 6 Standardizing Your Code Discusses HP aC++ keywords, Standard Exception Classes, and exceptions thrown by the Standard C++ library, and lists unsupported functionality. Chapter 7 Optimizing HP aC++ Programs Gives you information about optimizing your programs.
Instant Information CD, it may be a hot link to the manpage itself. From the HP-UX command line, you can enter “man audit” or “man 5 audit” to view the manpage. See man(1). Book Title The title of a book. On the Web and on the Instant Information CD, it may be a hot link to the book itself. KeyCap The name of a keyboard key. Emphasis Emphasized text. Bold Strongly emphasized text. Bold The defined use of an important word or phrase. ComputerOut Text displayed by the computer.
Table 1 HP-UX 11i Releases (continued) Release Identifier Release Name Supported Processor Architecture B.11.23 HP-UX 11i v2.0 Intel® Itanium® B.11.31 HP-UX 11i v3.0 Intel® Itanium® Edition Release Date Product Version Edition 1 August 2003 HP aC++ v A.05.50 Edition 2 March 2004 HP aC++ v A.05.55 Edition 3 September 2004 HP aC++ v A.05.55.02 Edition 4 December 2004 HP aC++ v A.06.00/A.05.60 Edition 5 September 2005 HP aC++ v A.06.05 Edition 6 May 2006 HP aC++ v A.06.
Please send comments to: c++-editor@cup.hp.com Please include document title, manufacturing part number, and any comment, error found, or suggestion for improvement that you have about this document.
1 Getting Started with HP aC++ The information in this document applies to the release of HP aC++ and HP ANSI C compilers version A.06.15 for the HP-UX 11i v3 operating system. The HP ANSI C compiler supports ANSI programming language C standard ISO 9899:1999. HP aC++ compiler supports the ISO/IEC 14882 Standard for the C++ Programming Language (the international standard for C++). Version A.06.
/usr/lib/hpux64/libstd.a (64-bit archive version) HP aC++ Runtime Support Library /usr/lib/hpux##/libCsup.so /usr/lib/hpux##/libstd.so and libstd_v2.so /usr/lib/hpux##/libstd_v2.so and librwtool_v2.so /usr/lib/hpux##/libstream.so Libraries in /usr/include/hpux## (where ## is 32 or 64 provided as part of the HP-UX core system) Standard C++ Library /usr/lib/hpux32/libstream.so /usr/lib/hpux32/libstream.a /usr/lib/hpux64/libstream.so /usr/lib/hpux64/libstream.
Debugging Programs You can use programming and debugging aides. HP Code Advisor HP Code Advisor is a code checking tool that can be used to detect programming errors in C/C++ source code. Use "/opt/cadvise/bin/cadvise" to invoke the tool. A brief description is available with the -help option. $ /opt/cadvise/bin/cadvise -help Additional information is available at: http://www.hp.com/go/cadvise/.
Examples of the aCC Command Following are some examples of the aCC command: Compiling and Renaming an Output File aCC -o prog prog.C This command compiles prog.C and puts the executable code in the file prog, rather than in the default file a.out. Compiling and Debugging aCC -g prog.C This command compiles prog.C and includes information that allows you to debug the program with the HP WDB debugger, wdb. Compiling Without Linking aCC -c prog.C This command compiles prog.
Files on the aCC Command Line Files containing source or object code to be compiled or linked by HP aC++ can be any of these files: • • • • • • A C++ Source File (.C file) Preprocessed Source Files (.i Files) Assembly Language Source Files (.s Files) Object Files (.o Files) Library Files (.a and .so Files) Configuration Files (.
Object Files (.o Files) Files with .o extensions are assumed to be relocatable object files that have to be included in the linking. The compiler invokes the linker to link the object files and create an executable file. Use the -c option to compile a C++ source file into a .o file. Library Files (.a and .so Files) Files ending with .a are assumed to be archive libraries. Files ending with .so are assumed to be shared libraries.
Environment Variables This section describes the following environment variables that you can use to control the HP aC++ or HP C compiler: • • • • • • “aCC_FULL_PATHNAMES Environment Variable” (page 35) “aCC_MAXERR Environment Variable” (page 35) “CXXOPTS Environment Variable” (page 35) “CCLIBDIR Environment Variable” (page 36) “CCROOTDIR Environment Variable” (page 36) “TMPDIR Environment Variable” (page 37) aCC_FULL_PATHNAMES Environment Variable Exporting the aCC_FULL_PATHNAMES variable causes the comp
The above command causes the -v and -l options to be passed to the aCC command each time you execute it. When CXXOPTS is set as above, the following two commands are equivalent: aCC -g prog.C aCC -v -g prog.C -lm CCLIBDIR Environment Variable The CCLIBDIR environment variable causes the aCC command to search for libraries in an alternate directory before searching in the default directories.
In this example, HP aC++ searches the directories under /mnt/CXX2.1 (/mnt/CXX2.1/ bin and /mnt/CXX2.1/lbin) for subprocesses rather than their respective default directories. TMPDIR Environment Variable The TMPDIR environment variable allows you to change the location of temporary files created by the compiler. The default directory is /var/tmp.
HP C By default, HP C is installed under the /opt/ansic directory. In earlier releases, the compiler driver (cc) looked for related files in subdirectories of the /opt/ansic directory. This prevented installation of more than one version of HP C on the same system at the same time. Only files in /opt/ansic are affected by floating installation. Regardless of the HP C driver you use, the compiler still uses the libraries, linker, and other files located in /usr/lib and /usr/ccs.
2 Command-Line Options You can specify command-line options to the aCC command. They allow you to override the default actions of the compiler. Each option begins with either a - or a + sign. Any number of options can be interspersed anywhere in the aCC command and they are typically separated by blanks. Unless specified otherwise, all options are supported by C and C++ compilers. Default options can be set using option configuration files. See “Configuration Files (.conf Files)” (page 34).
• • “Verbose Compile and Link Information” (page 122) “Concatenating Options” (page 125) Options to Control Code Generation The following options allow you to control the kind of code that the compiler generates: • • • • • -c +DOosname +DDdata_model +DSmodel -S -c You can use the -c option to compile one or more source files without entering the linking phase. When compiled, the compiler produces an object file (a file ending with .o) for each source file (a file ending with .c, .C, .s, or .i).
data_model can be one of the following: • • 32 (This value generates ILP32 code and is the default.) 64 (This value generates LP64 code.) This option specifies the data model for the compiler. Table 2-1 lists the differences between the two data models. Table 2-1 ILP32 Data Model and LP64 Data Model ILP32 Data Model LP64 Data Model The size of an int, long, or pointer data type is The size of an int data type is 32-bits. The size of a 32-bits. long or pointer data type is 64-bits.
HP-UX system by requesting the compiler to use instruction scheduling tuned to that particular model or processor. Using scheduling for one model or processor does not prevent your program from executing on another model or processor. If you plan to run your program on the same system where you are compiling, you do not need to use the +DS option. The compiler generates code tuned for your system.
Table 2-2 Size and Alignment of HP Compiler Data Types Data Type Size (in bytes) Alignment bool 1 1-byte char, unsigned char, signed 1 char 1 wchar_t 4 4 short, unsigned short, signed short 2 2 int, unsigned int 4 4 long, unsigned long 4* 4* float 4 4 __float80 16 16 __float128 16 8** _Decimal32 4 4 _Decimal64 8 8 _Decimal128 16 16 double 8 8 long double 16 8** long long, unsigned long long 8 8 enum 4 4 arrays Size of array element type Alignment of array
aCC -Ag++ -Wc,--fshort-enums foo.c The -fshort-enums option is used with the -Agcc or -Ag++ options to cause each enum type to be represented using the smallest integer type that is capable of representing all values of the enum type. Because it changes the representation of types, the code generated is not binary compatible with code compiled without the option.
-g0 The -g0 option causes the compiler to generate full debug information for the debugger. To suppress expansion of inline functions, use the +d option. -g1 Like the -g option, the -g1 option causes the compiler to generate minimal information for the debugger. It uses an algorithm that attempts to reduce duplication of debug information. To suppress expansion of inline functions, use the +d option. Differences Between -g, -g0, and -g1 Options The -g, -g0, and -g1 options generate debug information.
+macro_debug This option controls the emission of macro debug information into the object file. Set +macro_debug to one of the following required options: ref Emits debug information only for referenced macros. This is the default for -g, -g1, or -g0. all Emits debug information for all macros. This option can cause a significant increase in object file size. none Does not emit any macro debug information. One of the -g options (-g, -g0, or -g1) must be used to enable the +macro_debug option.
Currently only if, else, switch-case-default, and try-catch execution paths are recorded in the path table. If there is no condition statement inside a for, while, or do-while loop, then no excution path is recorded. Usage: The defined values for kind are: local Generates a local path table and records basic block-execution information in it at runtime. global Generates a global path table and records basic block-execution information in it at runtime. The global path table is a fixed size.
configurable global path table. The performance difference varies depending on the optimization level and how the program is written. none Disables generation of both the global and local path tables. The values can be combined by joining them with a colon. For example: +pathtrace=global:local The global_fixed_size and global values are mutually exclusive. If more than one of them are specified on the command line, the last one takes precedence. The same is true for the none value.
referenced using the +opts option to avoid listing them all directly on the command line. Example: The following command compiles file.C and reports errors but does not report any warnings. aCC -w file.C +w The +w option warns you about all questionable constructs and gives pedantic warnings. +w enables all checks except for the +wsecurity, +wendian, +wperfadvice, and+wlock warnings. Those need to be enabled explicitly if needed.
+Wcontext_limit +Wcontext_limit=num The +Wcontext_limi option limits the number of instantiation contexts output by the compiler for diagnostics involving template instantiations. At most num outermost contexts and num innermost contexts are shown. If there are more than 2*num relevant contexts, the additional contexts are omitted. Omitted contexts are replaced by a single line separating the outermost num contexts from the innermost num contexts, and indicating the number of contexts omitted.
+wlint This option enables several warnings in the compiler that provide lint like functionality. Checks are made for memory leaks, out-of-scope memory access, null pointer dereference, and out-of-bounds access. These compile time diagnostics can be very useful in detecting potential problems in the source code. To disable a specific warning introduced by +wlint, a +Wargs option can be used after the +wlint option. NOTE: The +wlint option is only supported on Itanium-based systems.
The higher the check level, the more warnings can be generated. Note that this may also generate more false positives. The default level is 2. Exception Handling By default, exception handling is enabled. To turn off exception handling, use the following option. +noeh +noeh The +noeh option disables exception handling. With exception handling disabled, the keywords throw and try generate an error. Mixing code compiled with and without +noeh may give undesired results. Example: aCC +noeh progex.
NOTE: When using -ext, specify it at both compile and link time. For example: aCC -ext foo.C compiles foo.C which contains a long long declaration. #include void main(){ long long ll = 1; cout << ll << endl; } +e The +e option is equivalent to the -ext option. Floating-Point Processing Options The following command-line options are used for floating-point processing.
The -fpeval option specifies the minimum precision to use for floating-point expression evaluation. This option does not affect the precision of parameters, return types, or assignments. The defined values for precision are: float Evaluates floating-point expressions and constants in their semantic type. double Evaluates float operations and constants using the range and precision of double, and evaluates all other floating-point expressions and constants in their semantic type.
+FP +FP[flags] The +FP option specifies how the runtime environment for floating-point operations should be initialized at program startup and used at link time. The default is that all trapping behaviors are disabled. The following flags are supported. Uppercase enables the flag, lowercase disables the flag. Table 2-3 Options for +FP[flags] Flag Description V (v) Trap on invalid floating-point operations. Z (z) Trap on divide by zero. O (o) Trap on floating-point overflow.
miss. For a given loop, the compiler divides cycles by the estimated loop length to arrive at the number of loop iterations for which to generate advanced prefetches. cycles must be in the range of 0 to 10000. A value of 0 instructs the compiler to use the default value, which is 480 cycles for loops containing floating-point accesses and 150 cycles for loops that do not contain any floating-point accesses.
-H cc -H file The -H option causes HP aC++/HP C to print the order and hierarchy of included files. The -H option dumps the include heirarchy to stderr so that the preprocessed compiler output indicates the include file nesting. +hdr_create aCC progname -c +hdr_create headername This option extracts the header from a program file and saves it as a precompiled header file. Example: aCC ApplicTemplate.
NOTE: The current directory is not searched when angle brackets (< >) are used with #include. Example: The following example directs the compiler to search in the directory include for #include files. aCC -I include file.C -I[-Idirs] -I- [-Idirs] [-Idirs] indicates an optional list of -Idirectory specifications in which a directory name cannot begin with a hyphen (-) character. The -I- option allows you to override the default -Idirectory search-path. This feature is called view-pathing.
Examples: With view-pathing off, the following example obtains all the quoted include files from dir1 only if they are not found in the directory of a.C and from dir2 only if they are not found in dir1. Finally, if necessary, the standard include directories are searched. Angle-bracketed include files are searched for in dir1, then dir2, followed by the standard include directories. aCC -Idir1 -Idir2 -c a.
NOTE: Some of the compiler’s header files are included using double quotes. Since the -I- option redefines the search order of such includes, if any standard headers are used, it is your responsibility to supply the standard include directories (/opt/aCC/ include* and /usr/include) in the correct order in your -I- command line.
If $DISPLAY is set, the default web browser is used. If the display variable is not set, a message is displayed.
num Description 2.0 < num < 9.0 Increasing levels of inliner aggressiveness. 9 Attempts to inline all functions other than recursive functions or those with a variable number of arguments. The default level depends on +Olevel as shown in the following table: level num 0 1 1 1 2 2 3 2 4 2 The +O[no]inline option controls the high-level optimizer that recognizes other opportunities in the same source file (+O3) or amongst all source files (+O4). For example, aCC +inline_level 3 app.
-exec -exec The -exec option indicates that any object file created will be used to create an executable file. Constants with a protected or hidden export class are placed in the read-only data section. This option also implies -Bprotected_def. It makes all defined functions and data (even tentatively defined data) protected by default (unless otherwise specified by another binding option or pragma).
The -L option must precede any -lname option entry on the command line; otherwise -L is ignored. This option is passed directly to the linker. Example: The following example compiles and links prog.C and directs the linker to search the directories and /project/libs for any libraries that prog.C uses (in this case, mylib1 and mylib2). aCC -L/project/libs prog.
-n -n The -n option causes 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 or the ld(1) manpage for more information. -N -N The -N option causes the program file produced by the linker to be marked as unsharable. For details and system defaults, refer to the description of ld in the HP-UX Reference Manual or the ld(1) manpage for more information.
Use the -r option to retain relocation information in the output file for subsequent relinking. -s -s Using the -s option causes 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. For details and system defaults, refer to the description of ld in the HP-UX Reference Manual or the ld(1) manpage for more information.
Options for Naming the Output File These options allow you to name the compilation output file something other than the default name. -o -o outfile The outfile parameter is the name of the file containing the output of the compilation. This option causes the output of the compilation 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 can use the -o option to specify the name and location of the object file. -.suffix -.
Handling Null Pointers Options The following options allow dereferencing of null pointers. -z -z The -z option disallows dereferencing of null pointers at run time. Fatal errors result if null pointers are dereferenced. If you attempt to dereference a null pointer, a SIGSEGV error occurs at run time. Example: aCC -z file.C The above command compiles file.C and generates code to disallow dereferencing of null pointers. For more information, see signal(2) and signal(5) manpages.
Compiling files at optimization level 2 ("-O" or "+O2") and above increases the amount of virtual memory needed by the compiler. In cases where very large functions or files are compiled at +O2, or in cases where aggressive (+O3 and above) optimization is used, ensure that the maxdsiz kernel tunable is set appropriately on the machine where compilation takes place. HP recommends a setting of 0x100000000, or 4 GB (the default for this parameter is 0x100000000, or 4 GB) for maxdsiz_64bit in such cases.
aCC +O1 prog.C +O2 +O2 The +O2 option performs level 2 optimization. This includes level 1 optimizations plus optimizations performed over entire functions in a single file. NOTE: Compiling with this optimization setting may require additional memory resources. Refer to the memory resource discussion above. Example: This command compiles prog.C and optimizes at level 2: aCC +O2 prog.C +O3 +O3 The +O3 option performs level 3 optimization.
NOTE: Compiling with this optimization setting may require additional memory resources. Refer to the memory resource discussion above. Example: This command compiles prog.C and optimizes at level 4: aCC +O4 prog.C If you run out of memory when compiling at +O4 optimization, there are several things you can do: • • • Compile at +O4 only those modules that need to be compiled at optimization level 4, and compile the remaining modules at a lower level.
This option is deprecated and may not be supported in future releases. Instead you can use +Olit=all for +ESlit and +Olit=none for +ESnolit options. -ipo The -ipo option enables interprocedural optimizations across files. The object file produced using this option contains intermediate code (IELF file). At link time,ld automatically invokes the interprocedural optimizer (u2comp), if any of the input object files is an IELF file. For optimization levels +O0 and +O1, this option is silently ignored.
A f(A constA x) { A a(x); return a; // Will not call the copy constructor if the } // optimization is enabled. This optimization will not be performed if the copy-constructor was not declared by the programmer. Note that although this optimization is allowed by the ISO/ANSI C++ standard, it may have noticeable side effects. Example: aCC -Wc,-nrv_optimization,on app.C +O[no]failsafe +O[no]failsafe The +O[no]failsafe option enables [disables] failsafe optimization.
NOTE: This option is deprecated and may not be supported in future releases. Instead you can use +Ofastoption. +O[no]conservative +O[no]conservative The +O[no]conservative option is deprecated and may not be used in future releases. It is approximately equivalent to +Oparmsoverlap +Onomoveflops. The default is +Onoconservative. +O[no]limit +O[no]limit The +Olimit option enables optimizations that significantly increase compile time or that consume a lot of memory.
NOTE: This option is supported in C-mode only. A warning is displayed in C++ when this option is used. +O[no]ptrs_strongly_typed +O[no]ptrs_strongly_typed The default is +Onoptrs_strongly_typed. +Optrs_strongly_typed is synonymous to +Otype_safety=strong. +Onoptrs_strongly_typed is synonymous to +Otype_safety=off. NOTE: This option is supported in C-mode only. A warning is displayed in C++ when this option is used.
NOTE: Using this option may result in reduced runtime performance. +O[no]datalayout +O[no]datalayout The +O[no]datalayout option enables [disables] profile-driven layout of global and static data items to improve cache memory utilization. This option is currently enabled if +Oprofile=use (dynamic profile feedback) is specified. The default, in the absence of +Oprofile=use, is +Onodatalayout.
NOTE: This option is deprecated and may not be supported in the future releases. +O[no]fltacc +O[no]fltacc=level The +O[no]fltacc option disables [enables] floating-point optimizations that can result in numerical differences. Any option other than +Ofltacc=strict also generates Fused Multiply-Add (FMA) instructions. FMA instructions can improve performance of floating-point applications. If you specify neither +Ofltacc nor +Onofltacc, less optimization is performed than for +Onofltacc.
is transformed as follows (note that x is invariant in the loop): x_inv = 1.0/x; for (int j=1;j<5;j++) a[j] = b[j] * x_inv; Since multiplication is considerably faster than division, the optimized program runs faster. +Ofrequently_called +Ofrequently_called=function1[,function2...] The named functions are assumed to be frequently called. This option overrides any information in a profile database.
The file indicated by filename should contain a list of function names, separated by commas or newlines. Optimization is enabled [disabled] for the named functions. +Oinlinebudget +Oinlinebudget=n NOTE: This option is deprecated as of version A.06.20 of the compiler and will not be supported in future releases. Instead you can use the +inline_level option. The +Oinlinebudget option controls the compile time budget for the inliner.
all All string literals and all const-qualified variables that do not require load-time or runtime initialization will be placed in a read-only data section. +Olit=all replaces the deprecated +ESlit option. const All string literals appearing in a context where const char * is legal, and all const-qualified variables that do not require load-time or runtime initialization will be placed in a read-only data section. +Olit=const is mapped to +Olit=all with a warning, except in C mode.
This option works like the OPT_LEVEL pragma. The option overrides the pragma for the specified functions. As with the pragma, you can only lower the level of optimization; you cannot raise it above the level specified by a basic +Olevel or -O option. To avoid confusion, it is best to use either this option or the OPT_LEVEL pragma rather than both. You can use this option at optimization levels 1, 2, 3, and 4. The default is to optimize all functions at the level specified by the basic +Olevel or -O option.
The default is +Oloop_transform. +O[no]loop_unroll +O[no]loop_unroll [=unroll_factor] The +O[no]loop_unroll option enables [disables] loop unrolling. This optimization can occur at optimization levels 2, 3, and 4. The default is +Oloop_unroll. The default is 4, that is, four copies of the loop body. The unroll_factor controls code expansion. Note that +Onoloop_unroll has no effect on loop unroll-and-jam.
It is recommended that you use the -N option when linking OpenMP programs to avoid exhausting memory when running with large numbers of threads. NOTE: HP aC++ version A.06.00 does not support C++ constructs in OpenMP. Use the +legacy_v5 option to use this option. +opts +opts filename The file indicated by filename contains a list of options that are processed as if they had been specified on the command line at the point of the +opts option. The options must be delimited by a blank character.
Use this option when linking an executable file, to remove functions not referenced by the application. You can also use this option when building a shared library to remove functions not exported and not referenced from within the shared library. This may be especially useful when functions have been inlined. NOTE: Any function having symbolic debug information associated with it is not removed. The default is +Onoprocelim at optimization levels 0 and 1; at levels 2, 3 and 4, the default is +Oprocelim.
The file indicated by filename contains a list of functions, separated by spaces or newlines. These functions are assumed to be rarely called. This option overrides any information in a profile database. +O[no]recovery +O[no]recovery The +O[no]recovery option generates [does not generate] recovery code for control speculation. The default is +Orecovery. For code that writes to uncacheable memory that may not be properly identified as volatile, the +Orecovery option reduces the risk of incorrect behavior.
The +O[no]store_ordering option preserves [does not preserve] the original program order for stores to memory that is visible to multiple threads. This does not imply strong ordering. The default is +Onostore_ordering. +Otype_safety +Otype_safety=kind The +Otype_safety option controls type-based aliasing assumptions. The defined values for kind are: off The default. Specifies that aliasing can occur freely across types. limited Code follows ANSI aliasing rules.
When this assertion is in effect, the optimizer can hold global variables in registers longer and delete inlined or cloned global procedures. This option is in effect only at +O4 level of optimization. All files compiled with +Owhole_program_mode must also be compiled with +O4. If any of the files were compiled with +O4 but were not compiled with +Owhole_program_mode, the linker disables the assertion for all files in the program. The default is +Onowhole_program_mode which disables the assertion.
are a comma-separated list of profile collection qualifiers. Supported profile collection qualifiers: arc Enables collection of arc counts. dcache Enables collection of data cache misses. stride Enables collection of stride data. loopiter Enables collection of loop iteration counts.. all Enables collection of all types of profile data. This is equivalent to +Oprofile=collect:arc,dcache,stride,loopiter. This is the default.
The default is +Onoinfo at levels 0-4. Parallel Processing Options HP aC++ provides the following optimization options for parallel code. -mt The -mt option enables multi-threading capability without the need to set any other flags, such as -l and -D. HP aC++ examines your environment and automatically selects and sets the appropriate flags. “Performance Options” (page 219). There are three possible sets of flags depending on your operating system and the libstd you use.
NOTE: For C++ and C -Ae -D_HPUX_SOURCE is set to be compatible with the default when -mt is not used. For C mode options -AC89, -AC99, and -Aa, -D_HPUX_SOURCE is also set. If you do not want to use-D_HPUX_SOURCE, you can undefine it by using -U. Example: -U_HPUX_SOURCE The following macros are used to compile multi-thread source code: • _REENTRANT Required by system header files that provide reentrant functions (suffixed by _r).
The +Oautopar option enables automatic parallelization of loops that are deemed safe and profitable by the loop transformer. Usage: This optimization allows applications to exploit otherwise idle resources on multicore or multiprocessor systems by automatically transforming serial loops into multithreaded parallel code. When the +Oautopar option is used at optimization levels +O3 and above, the compiler automatically parallelizes those loops that are deemed safe and profitable by the loop transformer.
NOTE: The +Oinfo option can be used to display additional information on the various optimizations being performed. +tls=[static|dynamic] +tls=[static|dynamic] The +tls option specifies whether references to thread local data items are to be performed according to the mode. Usage: +tls=mode The defined values of mode are: static This is a more efficient mode in which only thread local data in the program startup set can be accessed.
The -fast option selects a combination of optimization options for optimum execution speed and reasonable build times. This option is equivalent to +Ofast. Currently chosen options are: • • • • • +O2 +Ofltacc=relaxed +Onolimit +DSnative +FPD You can override any of the options in -fast by specifying a subsequent option after it. Use this option when porting C++ and C applications compiled on other UNIX operating systems to HP-UX.
The +Ofaster option is equivalent to +Ofast with an increased optimization level. The definition of +Ofaster may change, or the option may be deprecated in future releases. +[no]srcpos +[no]srcpos The +[no]srcpos option controls the generation of source position information for HP Caliper. The default is +srcpos. When +srcpos, is in effect, the compiler generates source position information.
You can override any of the options in -fast by specifying a subsequent option after it. This option is equivalent to +Ofast. Use this option when porting C++ and C applications compiled on other UNIX operating systems 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. +sb +sb The +sb option specifies unqualified char, short, int,long, and long long bitfields as signed. The default is +sb.
+wdriver The +wdriver option enables warnings for PA-RISC options that would otherwise be ignored silently on Integrity servers. With the addition of this option in version A.06.05, a number of warnings for PA options that had been reported by previous compiler versions were changed to be silently ignored by default. The intent is to give good PA-RISC to Integrity makefile compatibility by default, but provide this option to help users clean up unnecessary or misleading use of legacy options when desired.
This warning can be suppressed by adding an extra cast: fread((char*)(void*)ai, sizeof(char), 1, stdin); // OK Another +wendian warning captures cases where a cast when later dereferenced can cause endian issues. Preprocessor Options The following options are accepted by the preprocessor: -C -C Using the -C option prevents the preprocessor from stripping comments. See the description of cpp in the cpp(1) manpage for details.
#include void main(){ int i, j; #ifdef DEBUGFLAG int call_count=0; #endif /* ... */ } -E -E Using the -E option runs only the preprocessor on the named C++ files and sends the result to standard output (stdout). An exception to this rule is when-E is used with either the +m[d] or +M[d] option, the only output is the make dependency information. Unlike the -P option, the output of -E contains #line entries indicating the original file and line numbers.
+M[d] and +Make[d] +M[d] The +M[d] option directs a list of both the quote enclosed (" ") and angle bracket enclosed (< >) header files upon which your source code depends to stdout. The list is in a format accepted by the make command. If +Md is specified, the list is directed to a .d file. The .d file name prefix is the same as that of the object file. The .d file is created in the same directory as the object file. Usage: Use +Md when you also specify the -E or the -P option.
The -D option has lower precedence than the -U option. If the same name is used in both, the -U option and the -D option, the name is undefined regardless of the order of the options on the command line. Profiling Code Options HP compilers provides the following options for profiling your code. -G -G At compile time, the -G option produces code that counts the number of times each arc in the call graph is traversed.
The effect of this option can be overridden by setting the environment variable LD_PROFILEBUCKET_SIZE when running the instrumented program. This environment variable has no effect when building the instrumented program. Legal values are 16 (the default), and 32. See gprof(1) and ld(1) manpages for more details. Runtime Checking Options The +check options allow you to check your application for errors at runtime.
The -z option, which is part of +check=all, can be overridden by an explicit -Z option. +check=none The +check=none option turns off all runtime checking options. It disables any +check=xxxoptions that appear earlier on the command line. +check=bounds The +check=bounds option enables checks for out-of-bounds references to array variables or to buffers through pointer access. The check is performed for each reference to an array element or pointer access.
4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 5 int a[10]; char b[10]; int *ip = &a[0]; // points to global array int i; void *foo(int n) { return malloc(n * sizeof(int)); } int main(int argc, char **argv) { int j; // uninitialized variable int *lp = (int*)foo(10); // points to heap object // out of bound if "a.
Check off by one out-of-bounds access: $ RTC_NO_ABORT=1 a.out 10 Runtime Error: out of bounds buffer pointed by 0x400a1890 has 40 bytes (allocation stack trace: 0x040035c2, 0x04003612, 0xc0049c42), writing at 0x400a1890+40, 4 bytes ("rttest3.c", line 29) (0) 0x0000000004004770 _rtc_raise_fault + 0x560 at rtc_utils.c:164 [./a.out] (1) 0x0000000004008790 _rtc_oob_check_unknown_bounds + 0x1f0 at rtc_bounds.c:465 [./a.out] (2) 0x00000000040037b0 main + 0x1c0 at rttest3.c:29 [./a.
rtc_bounds.c:480 [./a.out] (2) 0x60000000c5f52440 libc_mem_common + 0x280 at infrtc.c:3286 [lib/hpux32/librtc.so] (3) 0x60000000c5f53650 _memset + 0x80 at infrtc.c:3521 [lib/hpux32/librtc.so] (4) 0x0000000004003760 main + 0x170 at rttest3.c:27 [./a.out] (5) 0x60000000c0049c50 main_opd_entry + 0x50 [/usr/lib/hpux32/dld.so] Runtime Error: out of bounds buffer pointed by 0x400a1890 has 40 bytes (allocation stack trace: 0x040035c2, 0x04003612, 0xc0049c42), writing at 0x400a1890-2054847100, 4 bytes ("rttest3.
void *thread1(void *arg) { pthread_mutex_lock(&mutex1); things_done++; pthread_mutex_unlock(&mutex1); return 0; } void *thread2(void *arg) { pthread_mutex_lock(&mutex2); things_done++; pthread_mutex_unlock(&mutex2); return 0; } int main(int argc, char *argv[]) { pthread_t th1, th2; pthread_create(&th1, NULL, thread1, (void*)NULL ); pthread_mutex_lock(&mutex1); things_done++; pthread_mutex_unlock(&mutex1); pthread_create(&th2, NULL, thread2, (void*)NULL ); sleep(10); return 0; } cc +check=lock simple_race.
+check=malloc The +check=malloc option enables memory leak and heap corruption checks at runtime. It will cause the user program to abort for writes beyond boundaries of heap objects, free or realloc calls for a pointer that is not a valid heap object, and out-of-memory conditions. Memory leak information is captured and written out to a log file when the program exits. The name of the logfile is printed out before program termination.
+check=stack:frame This option enables runtime checks for illegal writes from the current stack frame that overflow into the previous stack frame. +check=stack:variables This option enables runtime checks for illegal writes to the stack just before or after some variables on the stack. This includes array, struct/class/union, and variables whose address is taken. It also includes the overflow check for the stack frame (+check=stack:frame).
or in a directory specified by the GDBRTC_CONFIG environment variable. The default configuration used by the +check=thread option is: thread-check=1;recursive-relock=1;unlock-not-own=1; mix-sched-policy=1;cv-multiple-mxs=1;cv-wait-no-mx=1; thread-exit-own-mutex=1;thread-exit-no-join-detach=1;stack-util=80; num-waiters=0;frame_count=4;output_dir=.; If any thread error condition is detected during the application run, the error log is output to a file in the current working directory.
If the +check=bounds:pointer is on, +check=uninit will check pointer access for uninitialized memory read (UMR). To enable checking, the runtime system will initialize the heap objects and stack variables with a special pattern. If the pointer accesses an area containing the specified pattern for the specified length, then it assumes the read is UMR.
NOTE: This option is not supported in legacy HP C. This option is ignored with warnings in C-mode. -Aarm -Aarm This option enables the Tru64 UNIX C++ Annotated Reference Manual (ARM) dialect. This dialect was the default for Tru64 UNIX C++ compilers through compiler version 5.x. Support of this dialect is intended only to ease porting of existing Tru64 UNIX applications to HP-UX, and not for development of new programs.
NOTE: Some code that is a warning in C may be a fatal error in HP aC++. -Ag++ This option enables GNU C++ dialect compatibility. Not all GNU features are available, for instance, the asm mechanism. See also “-fshort-enums ” (page 43). -Agcc This option enables GNU C dialect compatibility. Not all GNU features are available, for instance, the asm mechanism. See also “-fshort-enums ” (page 43). NOTE: For HP aC++, the -Ae option must also be used.
+legacy_cpp +legacy_cpp The +legacy_cpp option enables the use of cpp.ansi ANSI C preprocessor. This option is available in C-mode only. NOTE: This option is not normally needed and may be deprecated in future. +legacy_v5 +legacy_v5 This option enables the use of the A.05.60 compiler. The default compiler is the A.06.00 compiler. +tru64 +tru64 This option causes return types of unprototyped functions to be treated as long, instead of int, matching Tru64 C behavior.
} return 100-k; // (1) } In the next example, with the option disabled, the code is illegal, because it redefines k in (2) when a previous definition (1) is considered to have occurred in the same scope. With the option enabled (-Wc,-ansi_for_scope,on), the definition in (1) is no longer in scope at (2) and thus the definition in (2) is legal.
The -tx,name option substitutes or inserts subprocess x, using name. The parameter, x, is one or more identifiers indicating the subprocess or subprocesses. The value of x can one or more of the following: Table 2-7 Identifiers x Description a Assembler (standard suffix is as) c Compiler (standard suffix is ctcom/ecom) C Same as c f Filter tool (standard suffix is c++filt) l Linker (standard suffix is ld) p Preprocessor (standard suffix is cpp.ansi).
aCC -tC,/users/proj/ecom file.C • Substituting for all Subprocesses: The following example compiles file.C and specifies that the characters /new/ aCC should be used as a prefix to all the subprocesses of HP aC++. For example, /new/aCC/ecom runs instead of the default /opt/aCC/lbin/ecom. aCC -tx,/new/aCC file.C -Wx,args -Wx,arg1[,arg2,..,argn] The -Wx,args option passes the arguments arg1 through argn to the subprocess x of the compilation.
aCC -Wl,-v file.C Passing Options to the Linker with -W The following example links file.o and passes the option -a archive to the linker, indicating that the archive version of the math library (indicated by -lm) and all other driver-supplied libraries should be used rather than the default shared library: aCC file.o -Wl,-a,archive -lm Passing Multiple Options to the Linker with -W The following example links file.
-Bdefault:filename The file indicated by filename contains a list of symbols, separated by spaces or newlines. These symbols are assigned the default export class. -Bextern -Bextern The specified symbols, or all undefined symbols if no list is provided, are assigned to default export class. Additionally, the compiler will inline the import stub for calls to these symbols. No compile time binding of these symbols will be done.
-Bhidden_def -Bhidden_def This option is the same as -Bhidden, but only locally defined (non-tentative) symbols, without __declspec(dllexport), are assigned the hidden export class. -Bprotected -Bprotected[=symbol[,symbol...]] The specified symbols, or all symbols if no symbols are specified, are assigned the protected export class.
NOTE: This option is deprecated as of version A.06.05 and if used, it issues a warning that -Bprotected_defis almost always what should be used in its place. Template Options By using a template option on the aCC command line, you can: • • • • Close a library or set of link units, to satisfy all unsatisfied instantiations without creating duplicate instantiations. Specify what templates to instantiate for a given translation unit.
NOTE: This option is supported in C++ only and ignored in C-mode. +inst_implicit_include +inst_implicit_include The +inst_implicit_include option specifies that the compiler use a process similar to that of the cfront source rule for locating template definition files.
• • .CC .cpp User-specified extensions must begin with a dot and must not exceed four characters in total. Any extension that does not follow these rules causes a warning and is ignored. These restrictions do not apply in HP aC++. Therefore, if your code was written for HP C++ and you wish to follow the cfront-based HP C++ template definition file naming conventions when compiling with HP aC++, you need to specify the +inst_include_suffixes option.
The +dumpversion option displays the simple version number of the compiler, such as A.06.25. Compare with the -V option, which displays more verbose product version information. +dryrun +dryrun The +dryrun option generates subprocess information for a given command line without running the subprocesses. It is useful in the development process to obtain command lines of compiler subprocesses in order to run the commands manually or to use them with other tools.
-I /opt/aCC/include -I /opt/aCC/include/iostream -I /usr -I /usr/include -I /usr/include -inline_power 0 app.C file name: app.C file size: app.o 444 + 16 + 1 = 461 process user sys real -----------------------------------------process: compiler 0.93 0.13 1.17 -----------------------------------------line numbers: app.C 7 lines/minute: app.C 396 LPATH=/usr/lib:/usr/lib/hpux32/pa1.1 :/usr/lib:/opt/langtools/lib:/usr/lib /opt/aCC/lbin/ld -o a.out /opt/aCC/lib/crt0.
aCC -V app.C aCC: HP aC++/ANSI C B3910B A.06.00 [Aug 25 2004] ld: 92453-07 linker ld HP Itanium(R) B.12.24 PBO 040820 (IPF/IPF) Concatenating Options You can concatenate some options to the aCC 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. Examples: Suppose you want to compile my_file.C using the options -v and -g1.
3 Pragma Directives and Attributes A pragma directive is an instruction to the compiler. You use a #pragma directive to control the actions of the compiler in a particular portion of a translation unit without affecting the translation unit as a whole. Put pragmas in your C++ source code where you want them to take effect. Unless otherwise specified, a pragma is in effect from the point where it is included until the end of the translation unit or until another pragma changes its status.
Use #pragma FINI to specify a termination function. The function specified by the FINI pragma is called after the 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 ...
LOCALITY #pragma LOCALITY "string" string specifies a name to be used for a code section. The LOCALITY pragma specifies a name to be associated with the code written to a relocatable object module. The string is forced to be uppercase in C. All code following the LOCALITY pragma is associated with the name specified in string. Code that is not headed by a LOCALITY pragma is associated with the name .text. The smallest scope of a unique LOCALITY pragma is a function.
ALIGN #pragma align N N is a number raised to the power of 2. HP aC++ supports user-specified alignment for global data. The pragma takes effect on next declaration. If the align pragma declaration is not in the global scope or if it is not a data declaration, the compiler displays a warning message. If the specified alignment is less than the original alignment of data, a warning message is displayed, and the pragma is ignored.
}; // sizeof(S2)==6, alignment 1 // S3 and S4 show that the pragma does not affect class fields // unless the class itself was defined under the pragma.
The pack pragma may be useful when porting code between different architectures where data type alignment and storage differences are of concern.
struct ST1 { char c1; T x; char c2; }; #pragma pack ST1 obj; // Same layout as S2 in the prior example template <> struct ST1 { char c1; char c2; }; // Explicit specialization // Undefined (unsupported) behavior // ST1 was defined under a #pragma pack 1 directive NOTE: The alignment of specializations and partial specializations of templates is undefined and unsupported if either the primary template or the specialization is under the influence of a #pragma pack directive.
To enable indirect access to unaligned data that has been assigned to another type, use the link in the library, -lunalign and arm the appropriate signal handler with a call to allow_unaligned_data_access. This causes every signal generated due to unaligned access to be intercepted and handled as expected. It also creates significant run-time overhead for every access to unaligned data, but does not impact access to aligned data.
UNALIGN #pragma unalign [1|2|4|8|16] typedef T1 T2; T1 and T2 have the same size and layout, but with specified alignment requirements. HP aCC supports misaligned data access using the unalign pragma. The unalign pragma can be applied on typedef to define a type with special alignment. The unalign pragma takes effect only on next declaration. If the unalign pragma declaration is not in the global scope or if it is not a typedef, compiler displays a warning message.
#pragma OPT_LEVEL 4 #pragma OPT_LEVEL INITIAL When used with a numeric argument, the OPT_LEVEL pragma sets the optimization level to 0, 1, 2, 3, or 4. The INITIAL argument causes the optimization level in effect at the start of the compilation, whether by default or specified on the command line, to be restored. Example: aCC -O prog.C #pragma OPT_LEVEL void A(){ // ... } #pragma OPT_LEVEL void B(){ // ... } 1 Optimize this function at level 1. 2 Restore optimization to level 2.
You must specify one of the optimization level options on the aCC command, otherwise this pragma is ignored. This pragma cannot be used within a function. FLOAT_TRAPS_ON Pragma #pragma FLOAT_TRAPS_ON [function {,function}] This pragma informs the compiler that the specified functions may enable 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.
• The pragma can be used without a function name, in which case it affects all functions until the next instance of the pragma or the end of the module. Consider the following: #pragma NOINLINE foo #pragma INLINE [foo will be inlined here] • • • • Inline functions (those declared with the inline keyword or as described above for C++), can be affected by #pragma NOLINLINE, which overrides the keyword.
Diagnostic Pragmas The following are the diagnostic pragmas supported by the HP aC++ compiler. diag_xxx Pragmas #pragma #pragma #pragma #pragma diag_suppress message1 message2 ... diag_warning message1 message2 ... diag_error message1 message2 ... diag_default message1 message2 ... Command-line options help you generate diagnostic messages for the entire build or for a specific source file. The diag pragmas let you manage warnings for a specific region within a source file.
#include typedef struct { int a; int b; } s; #pragma assert non_zero(sizeof(s) == 8) "sizeof assert failed" #pragma assert non_zero(offsetof(s,b) == 4) "offsetof assert failed" This pragma provides a similar behavior to that of the Tru64 C compiler. BINDING Pragma #pragma BINDING {hidden|protected|extern|default} Global symbols that follow this pragma will be given a specific binding.
FREQUENTLY_CALLED Pragma #pragma FREQUENTLY_CALLED [symbol{,symbol}] This file-scoped pragma identifies functions that are frequently called within the application. The pragma must be placed prior to any definition of or reference to the named function. If not, the behavior is undefined. FREQUENTLY_CALLED pragma is independent of +Oprofile=use in that it overrides any dynamically obtained profile information. HDR_STOP Pragma #pragma HDR_STOP This pragma instructs the compiler to stop precompiling headers.
and data references and bind them to locally defined code and data symbols. This pragma is equivalent to -Bprotected and is global in scope. This pragma is equivalent to #pragma PROTECTED. IF_CONVERT Pragma #pragma IF_CONVERT This block-scoped pragma instructs the compiler to If-Convert the current scope. There is no command-line option equivalent. If-Conversion is a compiler process that eliminates conditional branches by the use of predicates.
PTRS_TO_GLOBALS Pragma #pragma [NO]PTRS_TO_GLOBALS name This pragma aids alias analysis. It must be specified at global scope and immediately precede the declaration of the variable or entry named. The pragma tells the optimizer whether the global variable or entry name is accessed [is not accessed] through pointers.
With this pragma set to OFF, unsuffixed floating-point constants are treated as having type double. With this pragma set to ON, unsuffixed floating-point constants are treated as having type _Decimal64. The pragma can occur in either of these two contexts: • Outside external declarations In this case, the pragma takes effect from its occurrence until another FLOAT_CONST_DECIMAL64 pragma is encountered, or until the end of the translation unit.
#pragma STDC FENV_ACCESS OFF This pragma provides a means to inform the compiler when a program might access the floating-point environment to test flags or run under non-default modes. Use of the pragma allows certain optimizations that could subvert flag tests and mode changes such as global common sub expression elimination, code motion, and constant folding. The pragma can be placed either outside external declarations or preceding all explicit declarations and statements inside a compound statement.
where expression-stmt must have one of the following forms: • • • • • x binop = expr x++ ++x x---x Here, x is an lvalue expression with scalar type and expr is an expression with scalar type that does not reference the object designated by x. The atomic directive ensures that a specific memory location is updated atomically, rather than exposing it to the possibility of multiple, simultaneous writing threads.
See “OpenMP Clauses” (page 150) for more information. OMP FLUSH Pragma #pragma omp flush [(list)] where (list) names the variables that will be synchronized. The flush pragma, whether explicit or implied, specifies a cross-thread sequence point at which the implementation is required to ensure that all the threads in a team have a consistent view of certain objects in the memory.
where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses. clause can be one or more of the following: • • • • • • • • private(list) firstprivate(list) default(shared|none) shared(list) reduction(op:list) if (scalar-expression) copyin (list) num_threads The parallel pragma defines a parallel region, which is a region of the program that is executed by multiple threads in parallel. This is the fundamental construct that starts parallel execution.
OMP SECTIONS Pragma #pragma omp sections [clause1, clause2, ...] { #pragma omp section [ structured-block ] [#pragma omp section structured-block ] . . . } where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses. clause may be one of the following: • private(list) • firstprivate(list) • lastprivate(list) • reduction(op:list) • nowait The section or sections pragmas identify a construct that specifies a set of constructs to be divided among threads in a team.
clause may be one of the following: • • • • • • if (scalar-expression)) untied default (shared | none) private (list) firstprivate (list) shared (list) The TASK directive defines an explicit task. OMP TASKWAIT Pragma #pragma omp taskwait new-line The TASKWAIT directive specifies a wait on the completion of child tasks generated since the beginning of the current task.
firstprivate firstprivate(list) The firstprivate clause provides a superset of the functionality provided by the private clause. Variables specified in the list have private clause semantics described earlier. The new private object is initialized, as if there is an implied declaration inside the structured block and the initializer is the value of the original object.
shared shared(list) The shared clause causes the variables that appear in the list to be shared among all threads in a team. All threads within a team access the same storage area for the shared variables. copyin copyin(list) The copyin clause copies the value of master thread’s copy of a threadprivate variable to all other threads at the beginning of the parallel region. This clause can only be used with the parallel directive.
Attributes __attribute__ is a language feature that allows you to add attributes to functions (or with the aligned attribute, to variables or structure fields). The capabilities are similar to those of #pragma. It is more integrated into the language syntax than pragmas and its placement in the source code depends on the construct to which the attribute is being applied.
function. Within the lifetime of the memory object, no other calls to malloc routines should return the address of the same object or any address pointing into that object. Many wrappers around malloc() obey these rules. (The compiler already knows that malloc() itself obeys these rules.
attribute noreturn __attribute__ ((noreturn)) Similar to the NO_RETURN pragma, this attribute asserts to the optimizer that this function never returns to the call site. This allows the optimizer to delete any code after the function call. A C++ function marked with this attribute may still throw an exception unless it has an empty throw list.
4 Preprocessing Directives HP aC++ has its own, internal, preprocessor which is similar to the HP C preprocessor described in the HP C/HP-UX Reference Manual. When you issue the aCC command, your source files are automatically preprocessed.
Usage Guidelines Following are rules and guidelines for using preprocessor directives: • • • • • • A preprocessor directive must be preceeded by a pound sign (#). White-space characters may precede the # character. The # character is followed by any number of spaces and horizontal tab characters and a preprocessor directive. A preprocessor directive is terminated by a newline character. Preprocessor directives, as well as normal source lines, can be continued over several lines.
If the file name is enclosed in angle brackets (< >), the default system directories are searched to find the named file. If the file name is enclosed in double quotation marks (“ “), by default, the directory of the file containing the #include line is searched first, then directories named in -I options in left-to-right order, and last directories on a standard list. The arguments to the #include directive are subject to macro replacement before being processed.
The macro name is then replaced by the list of tokens wherever it appears in the source file (except inside of a string, character constant, or comment). A macro definition remains in force until it is undefined through the use of the #undef directive or until the end of the compilation unit. The replacement-list must fit on one line. If the line becomes too long, it can be broken up into several lines provided that all lines but the last are terminated by a backslash (\) character.
Specifying String Literals with the # Operator If a formal parameter in the macro definition directive’s replacement string is preceded by a # operator, it is replaced by the corresponding argument from the macro invocation, preceded and followed by a double-quote character (") to create a string literal. This feature, available only with the ANSI C preprocessor, may be used to turn macro arguments into strings. This feature is often used with the fact that HP aC++ concatenates adjacent strings.
printf("%d \n",firefly ); } Example 2 You can use the # and ## operators together: #include
NOTE: The result of the preprocessor concatenation operator ## must be a _single_ token. In particular, the use of ## to concatenate strings is redundant and not legal C or C++.
Parentheses surrounding each argument and the resulting expression ensure that the precedences of the arguments and the result interact properly with any other operators that might be used with the MAX macro. Using a macro definition for MAX has some advantages over a function definition. First, it executes faster because the macro generates in-line code, avoiding the overhead of a function call. Second, the MAX macro accepts any argument types.
#include #define distance1(rate,time) (rate * time) // replaced by : inline int distance2 ( int rate, int time ) { return ( rate * time ); } int main() { int i1 = 3, i2 = 3; ; printf("Distance from macro : %d\n", distance1(i1,i2) ) printf("Distance from inline function : %d\n", distance2(i1,i2) ); } Predefined Macros In addition to __LINE__ and __FILE__, HP aC++ provides the following predefined macros. The list describes the complete set of predefined macros that produce special information.
To use some HP-UX system functions you may need to define the symbol __HPUX_SOURCE. See stdsyms(5) manpage or the HP-UX Reference Manual for more information. Assertions (#assert, #unassert) Use #assert and #unassert to set a predicate name or predicate name and token to be tested with a #if directive. Note that you must also specify the -ext option at compile and link time.
Syntax conditional-directive ::= #if constant-expression newline #ifdef identifier newline [group] #ifndef identifier newline [group] #else newline [group] #elif constant-expression newline [group] #endif Here, constant-expression may also contain the defined operator: defined identifier defined (identifier) The constant-expression is like other C++ integral constant expressions except that all arithmetic is carried out in long int precision.
#ifdef max #ifndef min Using the #if Directive The #if preprocessing directive has the form: #ifconstant-expression Use #if to test an expression. HP aC++ evaluates the expression in the directive. If the expression evaluates to a non-zero value (TRUE), the code following the directive is included. Otherwise, the expression evaluates to FALSE and HP aC++ ignores the code up to the next #else, #endif, or #elif directive.
Examples The following examples show valid combinations of conditional compilation directives: #ifdef SWITCH #else #endif // compiled if SWITCH is defined // compiled if SWITCH is undefined // end of if #if defined(THING) #endif // compiled if THING is defined // end of if #if A>47 #else #if A < 20 #else // compiled if A is greater than 47 #endif #endif // // // // // compiled if A is less than 20 compiled if A is greater than or equal to 20 and less than or equal to 47 end of if, A is less than 20
with respect to the source code that is input to the preprocessor rather than the C++ source code that is output. HP aC++ defines two macros that you can use for error diagnostics. The first is __LINE__, an integer constant equal to the value of the current line number. The second is __FILE__, a quoted string literal equal to the name of the input source file. You can change __FILE__ and __LINE__ using #include or #line directives.
#pragma [token-list] Description The #pragma directive is ignored by the preprocessor, and instead is passed on to the HP aC++ compiler. It provides implementation-dependent information to HP aC++. Any pragma that is not recognized by HP aC++ will generate a warning from the compiler. The _Pragma operator, supported in non-strict C++98/C++03 mode and in all C++0x modes, has the effect of expanding the pragma specified in the string (in double-quotes) in just the way a #pragma directive would.
Warning Directive The #warning directive causes a diagnostic message, along with any included token arguments, to be produced by HP aC++. Syntax warning-directive ::= #warning [preprocessor tokens] Trigraph Sequences The C++ source code character set is a superset of the ISO 646-1983 Invariant Code Set. To enable you to use only the reduced set, you can use trigraph sequences to represent those characters not in the reduced set.
5 Using HP aC++ Templates The following sections overview template processing and describe the instantiation coding methods available to you.
Following is the overview of template processing:During compile-time instantiation, the compiler instantiates every template entity it sees in a translation unit provided it has the required template definition • • • The compiler places an instantiation in every .o file in which a template is used and its definition is known. The linker arbitrarily chooses a .o file to satisfy an instantiation request. Only the chosen instantiation appears in the a.out or .so file. Any redundant instantiations in other .
Examples Following are the examples for explicit and implicit instantiation: Class Template Following are examples of explicit and implicit instantiation syntax for a class template: template class Array; // // // // // forward declaration for the Array class template template class Array {/*...
template void sort (Array &); // // // // // // // // // request to explicitly instantiate the sort () template function NOTE is not required if the compiler can deduce this. void foo() { Array ai; sort(ai); } // use of the sort () // template function which // results in implicit instantiation NOTE: All template options on an aCC command-line apply to every file on the command line.
Why Use Compile-Time Instantiation Compile-time instantiation is the default. It is easy to use. Your code may compile faster when using compile-time instantiation. If your development environment uses a version control system that is sensitive to file modifications, you may want to use the current default, compile-time instantiation, to avoid major code rebuilds. NOTE: If you have used automatic instantiation with earlier versions of HP aC++ there may be some migration issues.
library on the link line. If such an object is defined in n shared libraries, it will be initialized and destructed n times at runtime. When building the same application with the current default, the libraries are not closed prior to the final link, and the likelihood of a template symbol being defined in more than one shared library will increase. Possible Duplicate Symbols in Archive Libraries If you have built an archive library using automatic instantiation in HP aC++ A.02.00 or A.01.
NOTE: This example is not meant to account for all cases of changed behavior. C++ Template Tutorial You can create class templates and function templates. A template defines a group of classes or functions. A template can have one or more types as parameters. When you use a template, you provide the particular types or constant expressions as actual parameters thereby creating a particular object or function. Class Templates A class template defines a family of classes.
The compiler automatically substitutes the parameters you specified, in this case int and 20, in place of the template formal parameters. You can create other instances of this template using other built-in types as well as user-defined types. Function Templates A function template defines a family of functions. To declare a function template, use the keyword template to define the formal parameters, which are types, then define the function in terms of those types.
6 Standardizing Your Code HP aC++ largely conforms to the ISO/IEC 14882 Standard for the C++ Programming Language (the international standard for C++).
bool values behave as integral types and participate in integral promotions. Types bool, char, wchar_t, and the signed and unsigned integer types are collectively called integral types. A synonym for integral type is integer type. The representations of integral types shall define values by use of a pure binary numeration system. Example void main(){ bool b=true; // Declare a variable of type bool and set it to true. if (b) // Test value of bool variable. b=false; // Set it to false.
Base b; Derived d; p = &b; q = dynamic_cast (p); // Yields zero. p = &d; q = dynamic_cast (p); // Yields p treated // as a derived pointer. } Static and dynamic casts are used to move within a class hierarchy. Static casts use only static (compile-time) information to do the conversions. In the example above, if p is really pointing to an object of type Derived, either a static or dynamic cast of p to q yields the same result. This is also true if p were the null pointer.
The syntax of conditions allows declarations in them. For example: class Base { virtual void f(); // Make Base a polymorphic type // other class details omitted }; class Derived : public Base { public: void derivedFunction(); // other class details omitted }; void Base::f() { // Define Base function.
{ // Define Base2 function. } class Derived : public virtual Base1, public virtual Base2 { // additional class details omitted }; void main() { Base1 *bp1; Base2 *bp2; Derived *dp; bp1 = new Derived; bp2 = new Derived; // dp = (Derived *) bp1; // Problem: compile time error // Can’t cast from virtual base. // dp = (Derived *) bp2; // Problem: compile time error // Can’t cast from virtual base. // dp = dynamic_cast bp1; // Problem: compile time error // Can’t cast from // non-polymorphic type.
Example class C { public: explicit C(int); }; C::C(int) { // empty definition } void main() { C c(5); c = C(10); // c = 15; // c + 20; // // // // // Legal Legal Produces a compile time error: Message: Cannot assign ‘C’ with ‘int’.
{ Vector operator + (Vector, Vector); Vector v1(10), v2(10); // create two 10 element vectors // details omitted // v1 = v2 + 5; // // // // // Not legal - generates compiletime error Message: Illegal typEs associated with operator ‘+’: ‘Vector’ and ‘int’. } mutable Keyword The mutable keyword is used in declarations of class members. It allows certain members of constant objects to be modified in spite of the const of the containing object.
c2.i = 2; c2.j = 3; // OK // OK } The mutable keyword can only be used on class data members. It cannot be used for const or static data members.
// in the outer space char const* name() const { return “Object from M::X”; } }; } } int main() { N::Object o1; M::Object o2; M::X::Object o3; printf(“This object is: %s.\n”, o1.name()); printf(“This object is: %s.\n”, o2.name()); printf(“This object is: %s.\n”, o3.
char const* f(double) { return “f(double) in main() translation unit”; } } An Auxiliary Translation Unit Following is an auxiliary translation unit that illustrates how namespaces interact across translation units. namespace { // An unnamed namespace unrelated to the // one in the other translation units. char const* f(double) { return “f(double) in auxiliary translation unit”; } } namespace N { // This namespace is the same as the // one in the main() translation unit. // We implement f(int) here.
NOTE: Using- directives are transitive. If you specify a using- directiveto one namespace which itself specifies a directive to another namespace, then names used in your scope will also be looked up in that other namespace. Using namespace directives can be a powerful means to migrate code to libraries that use namespaces. Occasionally, however, they may silently make unwanted names visible. It is therefore often suggested not to use using-directives unless the alternatives are very inconvenient.
diagnostic output. It also might be used to perform some standard service on an object such as via a database or I/O system. typeid Example Following is an example of the typeid keyword: # include # include class Base { virtual void f(); // Must have a virtual function // to be a polymorphic type. // additional class details omitted }; class Derived : public Base { // class details omitted }; void Base::f() { // Define function from Base.
the base class is provided by a library for which source code is not available. In other cases it may not be desirable, for example, some base class interfaces might be too big if all derived class functionality is included.
int main () { Base *p; // code which does either // p = new Base; or // p = new Derived; if (dynamic_cast (p)) cout << “Derived (or class derived from Derived) Object\n”; else cout << “Base Object\n”; } volatile Keyword The volatile keyword is used in declarations. It tells the compiler not to do aggressive optimization because a value might be changed in ways the compiler cannot detect. This keyword is part of the ANSI C standard with the same syntax and semantics.
wchar_t Keyword Wide (or multi-byte) characters can be declared with the data type wchar_t. It is an integral type that can represent all the codes of the largest character set among the supported locales defined in the localization library. This keyword was a typedef of the ANSI C standard. Usage This type was added to maintain ANSI C compatibility and to accomodate foreign (principally Oriental) character sets.
typename Keyword Use the typename keyword in template declarations to specify that a qualified name is a type, not a class member. Usage This construct is used to access a nested class in the template parameter class as a type in a declaration within the template. Example template class C1 { // class details omitted // T::C2 *p; typename T::C2 *p; // // // // Problem: flagged as compile-time error. T is a type, but T::C2 is not.
• Declare a class as a member of the class template (C2 below): template class C1 { class C2; // Additional details omitted }; • Declare a class in the context the template is declared within (C1 below): class C1; template class C2 { // details omitted }; Overloading new[] and delete[] for Arrays HP aC++ defines new and delete operators for arrays that are different from those used for single objects.
} // for this simple // example void C::operator delete[ ] (void *p) { cout << “Use operator delete[ ] from class C\n”; // here, real usage would include deallocation ::operator delete[ ] (p); // global operator // for this simple // example } int main() { C *p; p = new C[10]; delete[ ] p; } Notice that the new operator takes a class with an array specifier as an argument. The compiler uses the class and array dimension to provide the size_t argument.
These classes provide a common framework for the way errors are handled in a C++ program. System-specific error handling can be provided by creating classes that inherit from these standard exception classes. Example # include # include # include void f() { // details omitted throw range_error(string(“some info”)); } int main() { try { f(); } catch (runtime_error& r) { // handle any kind of runtime error including range_error cout << r.
what, when applied to the instance, returns a value equal to the argument to the constructor. Exceptions Thrown by the Standard C++ Library The following exceptions are thrown by the Standard C++ Library: • • • • operator new () and operator new [ ] throw a bad_alloc exception when they cannot obtain a block of storage. A dynamic_cast expression throws a bad_cast exception when a cast to a reference type fails. Operator typeid throws a bad_type exception when a pointer to a typeid expression is zero.
}; void Base::f() { // Define function from Base. } int main () { Base *p; // code which does either // p = new Base; or // p = new Derived; if (typeid(*p) == typeid(Base)) // Standard requires // comparison as part // of this class. cout << “Base Object\n”; cout << typeid(*p).name() << ‘\n’; // Standard requires // access to the name // of the type. } The standard requires the class type_info to be polymorphic.
Table 6-2 Unsupported Functionality Functionality Rogue Wave Standard C++ Library 2.2.1 Rogue Wave Standard C++ Library 1.2.1 libc ** Yes Provided as a class rather than a template. Not Applicable Yes The following C++ Not Applicable overloaded functions are not provided. (HP-UX System Libraries) Instead, ANSI C signatures are implemented.
Table 6-2 Unsupported Functionality (continued) Functionality Rogue Wave Standard C++ Library 2.2.1 Rogue Wave Standard C++ Library 1.2.
Table 6-2 Unsupported Functionality (continued) Functionality Rogue Wave Standard C++ Library 2.2.1 Rogue Wave Standard C++ Library 1.2.
7 Optimizing HP aC++ Programs HP C/HP aC++ provides options to the aCC command and pragmas to control optimization.
Specifically, level 2 provides the following: • • • • • • • • • Coloring register allocation. Induction variable elimination and strength reduction. Local and global common subexpression elimination. Advanced constant folding and propagation. (Simple constant folding is done by default.) Loop invariant code motion. Store/copy optimization. Unused definition elimination. Software pipelining. Register reassociation. Level 2 can produce faster runtime code than level 1 if programs use loops extensively.
Enabling Aggressive Optimizations To enable aggressive optimizations at the second, third, or fourth optimization levels, use the +Ofast option as follows: aCC +Ofast +O2 sourcefile.C or: aCC +Ofast +O3 sourcefile.C or: aCC +Ofast +O4 sourcefile.C This option enables additional optimizations at each level. NOTE: Use aggressive optimizations with stable, well-structured code. These types of optimizations give you faster code, but may change the behavior of programs.
aCC +O3 +Onolimit sourcefile.C or: aCC +O4 +Onolimit sourcefile.C By default, the optimizer limits the amount of time spent optimizing large programs at levels 2, 3, and 4. Use this option if longer compile times are acceptable because you want additional optimizations to be performed. Limiting the Size of Optimized Code You can disable optimizations that expand code size at the second, third, and fourth optimization levels by using the +Osize suboption, as follows: aCC +O2 +Osize sourcefile.
These steps are involved in performing profile-based optimization: 1. 2. 3. 4. Instrumentation Collecting Data for Profiling Maintaining Profile Data Files Performing Profile-Based Optimization Instrumentation To instrument your program, use the +Oprofile=collect option as follows: aCC +Oprofile=collect -O -c sample.C aCC +Oprofile=collect -O -o sample.exe sample.o The first command line uses the +Oprofile=collect option to prepare the code for instrumentation.
Example 1 In the following example, the FLOW_DATA environment variable is used to override the flow.data file name. The profile data is stored instead in /users/profiles/ prog.data. export FLOW_DATA=/users/profiles/prog.data aCC -c +Oprofile=collect sample.C aCC -o sample.exe +Oprofile=collect sample.o sample.exe < input.file1 aCC -o sample.exe +Oprofile=use +O3 sample.C Example 2 In this example, the +Oprofile=use:filename option is used to override the flow.
8 Exception Handling Exception handling provides a standard mechanism for coding responses to runtime errors or exceptions.
• • If an error occurs, code in the try block throws an exception to an appropriate catch clause. The catch clause is ignored if an error does not occur. When an exception is thrown, control is transferred to the nearest handler defined to handle that type of exception. Nearest means the handler whose try block was most recently entered by the thread of control, and not yet exited.
keyword comes before the function body’s opening brace, and the catch handler comes after the function body’s closing brace. #include #include #include void fx () { // ....... throw range_error(string(“some info”)); } int main ( ) try { fx (); } catch (runtime_error& r) { cout <
Rogue Wave Standard C++ Library 2.2.1 For both 32-bit and 64-bit libraries: • • libstd_v2.so and libstd_v2.a libCsup.so and libCsup.a Rogue Wave Standard C++ Library 1.2.1 and Tools.h++ 7.0.6 For both 32-bit and 64-bit libraries: • • • • libstd.so and libstd.a librwtool.so and librwtool.a libCsup.so and libCsup.a libstream.so and libstream.
ostr << “ or another” /*...*/ << endl; cout.write(ostr.str().c_str(), ostr.str().length()); Note that cout.flush may be needed if sharing the file with stdio. Required Command-line Options To use the multi-thread safe capabilities of the Standard C++ Library, you need to specify the following options at both compile and link time. Note that the options differ depending on which set of libraries you are using. Rogue Wave Standard C++ Library 2.2.
void f(ostream &out, int x, int y) { out << setw(3) << x << setw(10) << y; } This function would not be thread safe if called from multiple threads with the same object, since the width in the shared object could be changed at any time. Therefore, such objects are not protected from interactions between multiple threads, and the result of sharing such an object between threads is undefined. If the same object is shared between threads, a runtime crash, abort, or intermingled output may occur.
or by including a RogueWave tools.h++ header like tvset.h, tpmset.h, tpmset.h, tvset.h, tvmset.h, tvmset.h, tpmap.h, tpmmap.h, tpmmap.h, tvmap.h, and tvmmap.h. Since changing the rb_tree implementation to make it thread safe would break binary compatibility, the preprocessing macro, __HPACC_THREAD_SAFE_RB_TREE, must be defined. The macro is automatically defined in the Itanium® based environment.
Pthread library has no knowledge of C++ stack unwinding. Calling pthread_exit for will terminate the thread without doing proper C++ stack unwind. That is, destructors for local objects will not be called. (This is analogous to calling exit for single threaded program.) This can be fixed by calling destructors explicitly right before calling pthread_exit. Example: #include #include #include extern "C" int printf(const char*...
NOTE: vector::clear does not free all of the memory. The storage is put back into a free pool for that one container. This does not happen if a thread is canceled. In such cases, use thread specific data or thread local storage support along with pthread_cleanup_[push|pop] utilities. pthread_cancel is not supported. Function Scoping Theset_terminate, set_unexpected, and set_new_handler, functions apply to all threads in the process.
for each thread is allocated from the heap. The heap defaults 1 gigabyte, and the default stack size is 8 megabytes. See the linker option-N for increasing data area size to 2 gigabytes. If the dynamic threads mechanism is disabled, requests for additional threads will result in no additional threads being created. Programs should not assume that a request will result in additional threads for all requests.
• • • OMP_SCHEDULE environment variable: The default value for this environment variable is STATIC. OMP_NUM_THREADS environment variable: The default value is the number of physical processors on the system. OMP_DYNAMIC environment variable: The default value is FALSE. OpenMP Header File Every C++ program that contains OpenMP pragmas is to be compiled for the current version of HP-UX and must include the header file . If it does not, the OpenMP pragmas are ignored. The default path for
setenv OMP_SCHEDULE "kind[,chunk_size]" where, kind is either of of static, dynamic, or guided. This environment variable applies to for and parallel for directives that have the schedule type as runtime. The schedule type and chunk size for all such loops can be set at runtime by setting this environment variable to any of the recognized schedule types and to an optional chunk_size. The default value of the environment variable is a static schedule with a chunk_size of 1.
The OMP_NESTED environment variable enables or disables nested parallelism. Its value must be TRUE or FALSE. If the value is set to TRUE, nested parallelism is enabled and if the value is set to FALSE, the nested parallelism is disabled. The default value is FALSE. Runtime Library Functions in OpenMP The OpenMP library functions are external functions. The header declares three types of functions: • • • Several functions that can be used to control and query the parallel execution environment.
is the maximum number of threads that will be used. This function has effect only when called from serial portions of the program. If it is called from a portion of the program where the omp_in_parallel function returns non-zero, the behavior of this function is undefined. For more information on this subject, see the omp_set_dynamic and omp_get_dynamic functions. This call has precedence over the OMP_NUM_THREADS environment variable. omp_get_num_threads #include
omp_in_parallel #include int omp_in_parallel(void); The omp_in_parallel function returns non-zero if it is called within the dynamic extent of a parallel region executing in parallel; otherwise, it returns 0. This function returns non-zero from within a region executing in parallel, including nested regions that are serialized. omp_set_dynamic #include
omp_get_nested #include int omp_get_nested(void); The omp_get_nested function returns non-zero if nested parallelism is enabled and 0 if it is disabled. Lock Functions The functions described in this section manipulate locks used for synchronization. For the following functions, the lock variable must have type omp_lock_t. For nestable lock functions, the lock variable must have type omp_nest_lock_t. This variable must only be accessed through these functions.
void omp_set_nest_lock(omp_nest_lock_t *lock); Each of these functions blocks the thread executing the function until the specified lock is available and then sets the lock. A simple lock is available if it is unlocked. A nestable lock is available if it is unlocked or if it is already owned by the thread executing the function. For a simple lock, the argument to the omp_set_lock function must point to an initialized lock variable. Ownership of the lock is granted to the thread executing the function.
Timing Functions The functions described in this section support a portable wall-clock timer: • • omp_get_wtime omp_get_wtick omp_get_wtime #include double omp_get_wtime(void); The omp_get_wtime function returns a double-precision floating-point value equal to the elapsed wall clock time in seconds since some time in the past. The actual time in the past is arbitrary, but it is guaranteed not to change during the execution of the application program.
9 Tools and Libraries This chapter discusses tools and libraries bundled with HP aC++. It discusses the following topics: • “HP Specific Features of lex and yacc” (page 229) • “Creating and Using Libraries” (page 230) • “HP aC++ File Locations” (page 244) HP Specific Features of lex and yacc lex and yacc are bundled with HP aC++.
NOTE: When using lex and yacc: • Programs generated by yacc or lex can have many unreachable break statements, causing multiple aC++ warnings. • If you want to call the yacc generated routines, yyerror, yylex and yyparse, your program must include the yacc.h header file: #include For more information on these tools, refer to the lex and yacc man pages or the HP-UX Reference Manual. Another general source of information is lex and yacc by John R. Levine, Tony Mason, and Doug Brown.
Introduction HP aC++ provides the Rogue Wave implementation of the ANSI/ISO Standard C++ Library. This implementation includes the following features: • A subset of data structures and algorithms, updated from the original library developed at Hewlett-Packard by Alex Stepanov and Meng Lee and known as the C++ Standard Template Library (STL) NOTE: The public domain C++ Standard Template Library is not supported by this Standard C++ Library.
In future, most libraries will use the Standard C++ Library as their foundation. Using the Standard C++ Library, either directly or through an encapsulation such as Tools.h++ Library, ensures interoperability. This is important in large projects that may rely on communication among several libraries. A good thumb rule is to use the highest encapsulation level available to you, but make sure that the Standard C++ Library is available as the base for inter-library communication and operation.
Smaller Source Code There are approximately 50 different algorithms and about a dozen major data structures. This separation reduces the source code size, and decreases the risk of similar activities with dissimilar interfaces. In the absense of this separation, each algorithm must be implemented in each data structure. This requires additional member functions apart from those in the present scheme.
iterators in multiple threads as iterators are used to modify a non-const container. Use thread-safe wrappers, such as those provided by Tools.h++ Library to access a container from multiple threads. Standard C++ Library Reference The Standard C++ Library Reference provides an alphabetical listing of all of the classes, algorithms, and function objects in the prior Rogue Wave implementation of the Standard C++ Library.
It is provided as HTML formatted files. You can view these files with an HTML browser by opening the /opt/aCC/html/librwtool/ref.htm file. HP aC++ Runtime Support Library The HP aC++ runtime support library is provided as a shared library, /usr/lib/ libCsup.so and as an archive library, /usr/lib/libCsup.a.
NOTE: When you specify the -b option to create a shared library, these defaults do not apply. Linking with Shared or Archive Libraries If you want archive libraries instead of shared libraries, use the -a, archive linker option. To create a completely archived executable, use the +A option. To maintain compatibility with future releases, do not mix archive and shared libraries should not be mixed. Refer to the HP-UX Linker and Libraries User’s Guide for more information.
NOTE: Use the aCC command to create a C++ shared library. This ensures that static constructors and destructors are executed at appropriate times. Example The following example links util.o and creates the shared library util.so. aCC -b -o util.so util.o Using a Shared Library To use a shared library, include the name of the library in the aCC command line or use the-l option. The linker links the shared library to the executable file it creates.
Linking Archive or Shared Libraries When an archive and shared version of a particular library reside in the same directory, the linker links in the shared version by default. You can override this behavior with the -a linker option. NOTE: Use the +A option when using only archive libraries to create a completely archived executable. The -a option identifies the library type for the linker.
For example, when a module in an existing shared library requires a fix, recompile the fixed module with the +z or +Z option, and recreate the shared library with the -b option. Programs that use this library will now use the new versions of the routines. You do not have to relink programs that use this shared library because they are attached at run time. Advanced Shared Library Features This section explains additional things you can perform with shared libraries.
detects unresolved symbols at startup time, rather than during program execution. Immediate binding provides better interactive performance, but the program startup time is longer. To force immediate binding, use the option -Wl,-B,immediate. Example: aCC -Wl,-B,immediate draw_shapes.o -lshape To specify default binding, use the -Wl,B,deferred option. For more information, refer to the HP-UX Online Linker and Libraries User’s Guide.
Adding New Versions to a Shared Library To rebuild a shared library with new versions of some of the object files, use the aCC command and the -b option with the old object files and the newly compiled object files. The new source files should use the HP_SHLIB_VERSION pragma. Refer to HP-UX Online Linker and Libraries User’s Guide for more information. Standard HP-UX Libraries and Header Files HP-UX includes Several libraries that provide system services.
For -AP Standard Library The inline template function__rw_allocation_size can be explicitly specialized to return the number of units for each type’s use in any container: template <> inline size_t __rw-allocation_size(bar*,size_t) { return 1; } This would initially allocate one unit when dealing with containers of type bar. Alternatively, if RWSTD_STRICT_ANSI is not defined, then container member functionallocation_size can be used to directly set buffer_size, the number of units to allocate.
#ifndef DEFAULT // specialize default size // Default buffer size for containers. #ifdef _HP_NAMESPACE_STD namespace __rw { template <> inline size_t __rw_new_capacity(size_t __size, const printf("......\n"); // if small grow by 5, else by 1/8 current size return __size < 100 ? 5 : __size / 8; } } #else // -AP template <> inline size_t __rw_allocation_size(int*, size_t) { printf("......
#endif //printf("\n\n size used is //lastValue = info.arena; return 0; } %d \n",( info.arena -lastValue )/NUM); HP aC++ File Locations This section gives you information on the HP aC++ file locations.
— /usr/lib/hpux##/libstd_v2.so and librwtool_v2.so — /usr/lib/hpux##/libstream.so — Libraries in /usr/include/hpux## directory • • (## is 32 or 64 - provided as part of the HP-UX core system.) IOStream Library — /usr/lib/hpux32/libstream.so - 32-bit shared version — /usr/lib/hpux32/libstream.a - 32-bit archive version — /usr/lib/hpux64/libstream.so - 64-bit shared version — /usr/lib/hpux64/libstream.
10 Mixing C++ with Other Languages This chapter provides guidelines for linking HP aC++ modules with modules written in HP C and HP FORTRAN 90 on HP 9000 Series 700/800 systems.
data types. ANSI C and HP C++ also support a long double type. In addition, HP aC++ supports bool, wchar_t, long long, and unsigned long long data types. Pointers, structs, and unions that can be declared in C are also compatible. Arrays composed of any of the above types are compatible. C++ classes are generally incompatible with C structs.
function_declaration2 ... function_declarationN } Examples of extern "C" The following declarations are equivalent: extern “C” char* get_name(); // declare the external C module and extern “C” { char* get_name(); } // declare the external C module You can also use a linkage directive with all the functions in a file, as shown in the following example. This is useful when you use C library functions in a C++ program. extern “C” { #include “myclibrary.
Examples: HP aC++ Calling HP C The following examples show a C++ program, calling_c.C that calls a C function, get_name. The C++ program contains a main function. //************************************************************ // This is a C++ program that illustrates calling a function * // written in C. It calls the get_name() function, which is * // in the “get_name.c” module. The object modules generated * // by compiling the “calling_c.C” module and by compiling * // the “get_name.
{ static char name[80]; printf(“Enter the name: “); scanf(“%s”,name); return name; } /****************************************************/ Running the Example Following is a sample run of the executable file that results when you link the object modules generated by compiling calling_c.C and get_name.c: Enter the name:Joann Joann has a balance of 0 HP C Calling HP aC++ If you mix C++ modules with C modules, refer to “Linking Your HP aC++ Libraries with Other Languages” (page 258).
extern “C” void delete_obj (obj_ptr p); extern “C” void print_obj (obj_ptr p); struct obj { private: int x; public: obj() {x = 7;} friend void print_obj(obj_ptr p); }; // C interface routine to initialize an // object by calling the constructor. void initialize_obj(obj_ptr& p) { p = new obj; } // C interface routine to destroy an // object by calling the destructor. void delete_obj(obj_ptr p) { delete p; } // C interface routine to display // manipulating the object.
#if !defined(__LP64__) && !defined(__ia64) _main(); #endif /* Initialize the data object. Notice taking the address of f is compatible with the C++ reference construct. */ initialize_obj(&f); /* Call the routine to manipulate the fields */ print_obj(f); /* Destroy the data object */ delete_obj(f); } Compiling and Running the Sample Programs To compile the example, run the following commands: cc -ccfilename.c aCC -cC++filename.C aCC -oexecutable cfilename.o C++filename.
NOTE: As is the case with calling HP C from HP aC++, you must link your application using HP aC++. The main() Function In general, when you mix C++ modules with modules in HP FORTRAN 90, the overall control of the program must be written in C++. In other words, the main function must appear in a C++ module, and no other outer block should be present. Function Naming Conventions When you call an HP FORTRAN 90 function from HP aC++, keep in mind the differences in handling case sensitivity.
... pas_func( x ); ... // pas_func should accept // its parameters by reference } Using extern "C" Linkage To mix C++ modules with HP FORTRAN 90 modules, you must use extern "C" linkage to declare any C++ functions that are called from a non-C++ module and to declare the FORTRAN routines. Strings HP aC++ strings are not the same as HP FORTRAN 90 strings. In FORTRAN 90, the strings are not null terminated. Also, strings are passed as string descriptors in FORTRAN 90.
11 Distributing Your C++ Products Distribute your products in such a way that your customer does not need to use the HP aC++ compiler or driver. That is, only distribute executables and shared libraries. If you write code in HP aC++ and distribute any of the following C++ files to your customers, read the following sections for recommendations and legal requirements. • Shared libraries containing C++ code with the exception of the following libraries: — /usr/lib/hpux##/libCsup.so — /usr/lib/hpux##/libstd.
NOTE: If you distribute either executable files or shared libraries as part of your product, do not ship these HP aC++ runtime libraries with your product in such a way that it results in overwriting a newer library version with an older, incompatible version. Ensure that an older library version is not installed over a newer one. Linking Your HP aC++ Libraries with Other Languages The C++ language requires that non-local static objects be initialized before any function or object is used.
HP aC++ Files You May Distribute You can package and redistribute the following HP aC++ components to your customers. The following HP aC++ runtime libraries are provided as a patch to the HP-UX core system: • • • • /usr/lib/hpux##/libCsup.so /usr/lib/hpux##/libstd.so and libstd_v2.so /usr/lib/hpux##/librwtool.so and librwtool_v2.so /usr/lib/hpux##/libstream.so where ## is 32 or 64, which are provided as part of the HP-UX core system.
12 Migrating from HP C++ (cfront) to HP aC++ This chapter discusses differences in syntax and functionality that you need to consider when migrating from HP C++ (cfront) to HP aC++.
3. Compile and fix syntax errors. • Note that cfront-generated object code and libraries are not compatible with those produced by aCC. • If your program uses operator new, allow for memory allocation exceptions that may occur. Modify your cfront code to handle memory allocation failures to avoid a program abort. 4. Make library changes. Begin migration to the Standard C++ Library and Tools.h++ Library. Make template changes.
The following sections describe differences in command-line options: • “New Command-Line Options” (page 263) • “Obsolete Command-Line Options” (page 263) • “Changed Command-Line Options” (page 265) New Command-Line Options Table 12-1 describes the new options for HP aC++. These options are not available for HP C++ (cfront). However, if a related option exists, it is noted here. See Chapter 2: “Command-Line Options” (page 39) to for a complete list of HP aC++ command-line options.
Table 12-2 Obsolete Command-Line Options (continued) Option Description +eh Enables exception handling in HP C++. In HP aC++, exception handling is enabled by default. To disable exception handling off, compile with the +noeh option. Library Option -depth In HP C++, this option instructs runtime system to traverse the shared library list in a depth-first manner when calling static constructors and when loading the libraries.
Table 12-2 Obsolete Command-Line Options (continued) Option Description +a0 Causes the translator to produce Classic C style declarations. +a1 Causes the translator to produce ANSI C style declarations. -F Runs only the preprocessor and translator, and sends the resulting source code to standard output (stdout). -Fc Similar to the -F option, except that C source code is generated. +i Generates an intermediate C language source file that has the file name suffix ..c in the current directory.
Table 12-3 Changed Command-Line Options (continued) Option Description -tx,name The following values for x are related to translator mode and template subprocesses and are not supported in HP aC++.
Exception Handling is the Default In HP aC++ exception handling is enabled by default. Use the +noeh option to disable exception handling. NOTE: With exception handling disabled, the keywords throw and try generate a compiler error. The HP C++ (cfront) compiler, behaves differently; the default is exception handling off. To turn it on, you must use the +eh option. If your executable throws no exceptions, object files compiled with and without the +noeh option can be mixed freely.
void foo1() { X* xp1 = new(nothrow())X; // returns 0 when creating a nothrow // object, if space is not allocated } void foo2() { X* xp2 = newX: } // may throw bad_alloc void main() { try { foo1(); foo2(); } catch (bad_alloc) { // code to handle bad_alloc } catch(...) { // code to handle all other exceptions } } Possible Differences when Exiting a Signal Handler Behavior when exiting a signal handler through a throw may differ between the two compilers.
Calling unexpected Unlike HP C++, in HP aC++, when an unexpected handler wants to exit through a throw, it must throw an exception that is legal according to the exception specification that calls unexpected(), unless that exception specification includes the predefined type bad_exception. If it includes bad_exception, and the type thrown from the unexpected handler is not in the exception specification, then the thrown object is replaced by a bad_exception object and throw processing continues.
set_unexpected( my_unexpected_handler ); try { foo(); } catch(...) { printf(“fail - not legal in aCC\n”); } return 0; } Unreachable catch Clauses Unreachable catch clauses are diagnosed by HP C++ but not by HP aC++. For example, class C { // ... }; class D : public C { // ... }; ... catch(C) { } catch(D) { // Unreachable since previous catch masks this one. // Throw of D will be caught by catch for base class. } catch(C * ) { } catch(D * ) { // Unreachable since previous catch masks this one.
public: D1() {}; }; class D2 : public C { public: D2() {}; }; class E: public D1, public D2 { public: E() {}; }; int main() { E e; try { throw e; } catch(C) { printf(“caught } catch(D1) { printf(“caught } catch(D2) { printf(“caught } catch(E) { printf(“caught } try { throw & e; } catch(C*) { printf(“caught } catch(D1*) { printf(“caught } catch(D2*) { printf(“caught } catch(E*) { printf(“caught } return 0; } a C object\n”); a D1 object\n”); a D2 object\n”); an E object\n”); ptr to C object\n”); ptr to
Migration Considerations when Using Libraries The following sections contain information about library migration from HP C++ (cfront) to HP aC++. Standards Based Libraries HP aC++ provides the following libraries that are not part of the HP C++ (cfront) compiler: • • • Standard C++ Library Tools.h++ Library HP aC++ Runtime Support Library HP recommends that you use these standards based libraries whenever possible, instead of the cfront compatibility libraries.
To invoke a manpage from the command line, enter 3s after the man command and before the manpage name. Example: Enter the following command to invoke the manpage for filebuf: man 3s filebuf Header Files Use the following header files with the IOStream library. • • • • • • iostream.h - I/O streams classes ios, istream, ostream, and streambuf fstream.h strstream.h - streambuf specialized to arrays iomanip.h - predefined manipulators and macros stdiostream.
• • cplxops(3C++) - Complex Number Operators cplxtrig(3C++) - Trigonometric and Hyperbolic Functions for Complex Numbers Header File The Complex library uses the complex.h header file. HP C++ (cfront) Task Library Not Supported The task library, that is part of the HP C++, is not included with HP aC++. To develop multi-threaded applications with HP aC++, use the pthreadprogramming interface routines that are available as part of HP DCE/9000.
to an HP aC++ program. In addition to keyword changes, there are changes in C++ Semantics and C++ Syntax. Changes in C++ Semantics Following lists the differences in code behavior when you migrate from HP C++ to HP aC++: • • • • Implicit Typing of Character String Literals Overload Resolution Ambiguity of Subscripting Operator Execution Order of Static Constructors in Shared Libraries More Frequent Inlining of Inline Code NOTE: These differences can occur inspite of compiling your code without errors.
Overload Resolution Ambiguity of Subscripting Operator HP C++ and HP aC++ have different overload resolution models. When you migrate to HP aC++, you may see an overload resolution ambiguity for the subscripting operator. The following code illustrates the problem: struct String { char& operator[](unsigned); operator char*(); // ...
void f(String &s) { s[0] = ‘0’; } Execution Order of Static Constructors in Shared Libraries In HP C++ (cfront), static constructors in shared libraries listed on the link-line are executed, by default, in left-to-right order. HP aC++ executes static constructors in depth-first order; that is, shared libraries on which other files depend are initialized first. Use the -depth command-line option on the CC command line for enhanced compatibility with HP aC++.
• • • • • • • • • “Duplicate Formal Argument Names” (page 283) “Ambiguous Function or Object Declaration” (page 283) “Overloaded Operations ++ and --” (page 284) “Reference Initialization” (page 284) “Using operator new to Allocate Arrays” (page 285) “Parentheses in Static Member Initialization List” (page 285) “&qualified-id Required in Static Member Initialization List” (page 286) “Non-constant Reference Initialization” (page 286) “Digraph White Space Separators” (page 287) Explicit int Declaration In H
The following code currently compiles without errors with HP C++ and HP aC++. In the future, HP aC++, will generate an error. int main(int argc) { for (int i = 1; i < argc; ++i) { } for (i = 0; i < argc; ++i) { } } Correct the code as follows: int main(int argc) { int i; for (i = 1; i < argc; ++i) { } for (i = 0; i < argc; ++i) { } } This code complies with ANSI/ISO C++ International Standard syntax and compiles with both compilers.
template class BaseT { public: T t; int i; }; template class DerivedT : public BaseT { public: void foo1 () { t = 1; i = 1; } // // warning 721 t and i could be global. void foo2 () { this->t = 2; this->i = 2; } // Correct syntax, no warning. }; DerivedT d; // Here is the point of instantiation. Tokens after #endif In HP C++, any character that follows the #endif preprocessor statement causes a warning and is ignored.
int f(int i); overload int f(float f); int main () { return 1; } // Remove the word overload. Dangling Comma in enum In HP C++, a comma following the last element in an enum list is ignored. In HP aC++, a comma following the last element in an enum list generates an error. To avoid this error, remove the comma after the last element. Example: HP C++ accepts the following code. HP aC++ generates an error stating that the comma (,) is unexpected.
Example: Compiling the following code on HP C++ does not generate a warning or an error. Compiling the code on HP aC++ generates an error stating that the friend declaration for B is not in the right form for either a function or a class. class foo{ public: friend bar; }; int main (){ return 1; } // Need to say: friend class B Incorrect Syntax for Calls to operator new In HP C++, you can use incorrect syntax to call operator new.
> int main(){ } Duplicate Formal Argument Names In HP C++, duplicate formal argument names are allowed. In HP aC++, duplicate formal argument names generate an error. To avoid this, use unique formal parameter names. Example: The following code compiles with HP C++. With HP aC++, an error is generated stating that symbol aParameter has been redefined and where it was previously defined.
Overloaded Operations ++ and -You must use the overloaded operations ++ and -- correctly. These operations require a member function with one argument. If the function has no argument, a warning is issued and a postfic is assumed in HP C++. In HP aC++, the inconsistency between the overloaded function usage and definition is considered an error. To avoid this error, change the class definition so that each overloaded function definition has the correct number of arguments.
Compiling the code with HP aC++ generates an error like the following: Error: File “nonConstRef.C”, Line 6 Type mismatch; cannot initialize a ‘int &’ with a ‘char’. Try changing ‘int &’ to ‘const int &’. To successfully compile with both compilers, make the following changes to the code: void f() { char c = 1; const int & r = c; } Using operator new to Allocate Arrays In HP C++, operator new is called to allocate memory for an array. In HP aC++, operator new [] is called to allocate memory for an array.
Error: File “DDB4270.C”, Line 7 A pointer to member cannot be created from a parenthesized or unqualified name. To successfully compile the code, remove the parentheses from the last line. Example: class A { public: int i; static int (A::*p); }; int (A::*(A::p)) = &A::i; &qualified-id Required in Static Member Initialization List In HP C++, you can use an unqualified function name in a static member initialization list.
Example: void f(int &); int main () { f(3); return 0; } Compiling this code with HP C++ generates the following warning: CC: “DDB04313A.C”, line 4: warning: temporary used for non-const int & argument; no changes will be propagated to actual argument (anachronism) (283) Compiling the above code with HP aC++ generates the following error: Future Error: File “DDB04313A.C”, Line 4 The initializer for a non-constant reference must be an lvalue. Try changing ‘int &’ to ‘const int &’.
Migration Considerations when Using Templates In HP aC++, templates are processed differently than in HP C++ (cfront). HP aC++ does not have a repository. All instantiations are placed in an object (.o) file (with additional information in a .Ia file if you specify the +inst_auto command-line option). You cannot modify these files as was possible with the files in a repository. See Chapter 5: “Using HP aC++ Templates” (page 173) for more information.
Converting Directed Mode to Explicit Instantiation If you use directed mode instantiation with the cfront based compiler, an awk script can be used to convert your file to an instantiation file that uses the explicit instantiation syntax: Example: #!/usr/bin/ksh # For a Directed-Mode Instantiation file that is the parameter # to the script, create a file that can be compiled with the # aC++ compiler using the Explicit Instantiation Syntax. # (Note that this will only work for classes.
A Diagnostic Messages The aC++ compiler can issue a large variety of diagnostics in response to unexpected situations or suspicious constructs. This appendix presents a summary of these diagnotics organized into the following sections: • “aCC Message Catalog” (page 291) • “Frequently Encountered Messages” (page 292) aCC Message Catalog The aCC message catalog is located in the following directory: /opt/aCC/lib/nls/msg/C/aCC.
Warnings Warnings identify bugs in code, often because the code triggers behavior that is not precisely defined by the C++ standard. Suggestion/Information You must use the -w option to view these diagnotics. Without the -w option, the compiler identifies more suspicious constructs. Tool Errors Sometimes, HP aC++ fails in a component that is not specific to the C++ language. In such a case, a tool error is emitted. This error indicates defect in the compiler.
Glossary A aggressive optimization Optimization that changes the behavior of structured code. This is a superset of basic optimizations. anachronistic constructs Elements of the C++ language that are not supported in future releases. archive library A collection of object files grouped using the ar command. At link time, only object files with symbols are extracted from the library. argument declaration file A file containing the declaration of a class, struct, union, or enum types for templates.
destructor A function that cleans up or deinitializes each object of a class immediately before the object is destroyed. Destructors are executed when the program leaves the scope in which objects are defined and when any object is destroyed by delete. Destructors have the same name as their class, prefixed by a tilde, ~. directed instantiation Template instantiation that is specified by the developer through an explicit instantiation or a compiler command-line option.
L lex A program generator for lexical analysis of text. link unit A single entity submitted to the linker. A link unit can be an object file (.o file, the output of a translation unit), an archive library (.a file), or a shared library (.so file). load compile Invoking the compiler using the +hdr_use option, and a manual precompiled header file. M member data Any data element declared to be part of a class. member function Any function declared to be part of a class.
profile-based optimization An optimization in which the compiler and linker work together to optimize an application based on profile data obtained from running the application on a typical input data set. protected member A protected member of a class is a data member or member function that is only accessible from within the class defining the member, or from any class derived from that class, or from any friends of the class defining the protected member.
Index Symbols # operator, 161 ## operator, 161 .
+Ofaster, 93 +Ofrequently_called, 78 +Oinlinebudget, 79 +Ointeger_overflow, 80 +Olevel, 80 +Olit, 79 +Onolibcalls, 64 +Oprefetch_latency, 55 +Oprofile, 87 +opts, 83 +Orarely_called, 84 +Oshortdata, 85 +Otype_safety, 86 +Ounroll_factor, 86 +p, 48 +pathtrace, 46 +profilebucketsize, 100 +sb, 95 +time, 123 +tls=[static|dynamic], 92 +tru64, 113 +ub, 95 +uc, 95 +unum, 44 +w, 49 +w64bit, 95 +Wargs, 49 +Wcontext_limit, 50 +We, 50 +Weargs, 50 +wendian, 96 +wlint, 51 +wlock, 92 +Wmacro, 51 +wn, 49 +wperfadvice, 51 +w
-Z, 68 -z, 68 configuration file, 34 containers, 241 CROOTDIR, 36 CXXOPTS, 35 D #define, 159 E #endif, 166 environment variable, 35 environment variables in OpenMP, 221 exception handling, 211 ANSI/ISO C++ Intl. Std.
IVDEP, 138 LOCALITY, 129 LOCALITY_ALL, 129 NO_INLINE, 138 NO_RETURN, 138 NODEPCHK, 138 OMP ATOMIC, 145 OMP BARRIER, 146 OMP CRITICAL, 146 OMP FLUSH, 147 OMP FOR, 146 OMP MASTER, 147 OMP ORDERED, 147 OMP PARALLEL, 147 OMP PARALLEL FOR, 148 OMP PARALLEL SECTIONS, 148 OMP SECTIONS, 149 OMP SINGLE, 149 OMP TASK, 149 OMP TASKWAIT, 150 OMP THREADPRIVATE, 150 OPT_LEVEL, 135 OPTIMIZE, 136 PACK, 130 POP, 142 PROTECTED, 142 PTRS_STRONGLY_TYPED, 142 PUSH, 143 RARELY_CALLED, 143 STDC CX_LIMITED_RANGE, 143 STDC FENV_ACC