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............................................................................
HP aC++.........................................................................................................................35 HP C..............................................................................................................................35 Setting up Floating Installation.....................................................................................36 2 Command-Line Options..........................................................................................................
Exception Handling............................................................................................................50 +noeh.............................................................................................................................50 Extensions to the Language................................................................................................50 -ext.........................................................................................................................
-Q...................................................................................................................................63 -r....................................................................................................................................63 -s....................................................................................................................................64 -usymbol..............................................................................................
+O[no]initcheck........................................................................................................76 +O[no]inline.............................................................................................................76 +Oinlinebudget........................................................................................................76 +Olit..........................................................................................................................
+DSmodel......................................................................................................................92 Porting Options...................................................................................................................93 -fast................................................................................................................................93 +sb...............................................................................................................
-AOa and -AOe............................................................................................................111 -AP...............................................................................................................................111 +legacy_cpp.................................................................................................................111 +legacy_v5...................................................................................................................
FINI..............................................................................................................................125 Copyright Notice and Identification Pragmas.................................................................126 COPYRIGHT...............................................................................................................126 COPYRIGHT_DATE....................................................................................................126 LOCALITY................
STDC CX_LIMITED_RANGE Pragma........................................................................141 STDC FP_CONTRACT Pragma..................................................................................142 STDC FENV_ACCESS Pragma...................................................................................142 UNROLL_FACTOR Pragma.......................................................................................142 OMP ATOMIC Pragma.............................................................
Usage Guidelines.........................................................................................................154 Source File Inclusion (#include, #include_next)..........................................................154 Syntax.....................................................................................................................154 Description.............................................................................................................154 Examples...................
Error Directive (#error)................................................................................................167 Syntax.....................................................................................................................167 Example..................................................................................................................167 Warning Directive........................................................................................................167 Syntax.....
mutable Keyword........................................................................................................183 Usage......................................................................................................................183 Example..................................................................................................................183 namespace and using Keywords.................................................................................
Limiting the Size of Optimized Code....................................................................204 Combining Optimization Options.........................................................................204 Profile-Based Optimization.........................................................................................204 Instrumentation......................................................................................................205 Instrumenting Code at Level 4 Optimization................
OMP_SCHEDULE..................................................................................................219 OMP_NUM_THREADS.........................................................................................220 OMP_DYNAMIC...................................................................................................220 OMP_NESTED.......................................................................................................220 Runtime Library Functions in OpenMP........................
Tools.h++ Library....................................................................................................232 HP aC++ Runtime Support Library........................................................................233 IOStream Library...................................................................................................233 Standard Components Library Not Provided.......................................................233 Linking to C++ Libraries..........................................
Using the extern "C" Linkage Specification...........................................................246 Syntax of extern "C"................................................................................................246 Examples of extern "C"...........................................................................................247 Differences in Argument Passing Conventions.....................................................247 The main() Function...................................................
Unreachable catch Clauses..........................................................................................268 Throwing an Object having an Ambiguous Base Class..............................................268 Migration Considerations when Using Libraries.............................................................270 Standards Based Libraries...........................................................................................270 HP C++ (cfront) Compatibility Libraries.........................
Verbose Template Processing Information..................................................................286 Common Template Migration Syntax Changes..........................................................286 The cfront Implicit Include Convention......................................................................286 Converting Directed Mode to Explicit Instantiation...................................................287 A Diagnostic Messages...............................................................
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...................................................................39 Size and Alignment of HP Compiler Data Types.......................................................40 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.
Book Title KeyCap Emphasis Bold Bold ComputerOut UserInput Command Variable [] {} ... | From the HP-UX command line, you can enter “man audit” or “man 5 audit” to view the manpage. See man(1). The title of a book. On the Web and on the Instant Information CD, it may be a hot link to the book itself. The name of a keyboard key. Emphasized text. Strongly emphasized text. The defined use of an important word or phrase. Text displayed by the computer. Commands and other text that you type.
Publishing History 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.10 Edition 7 November 2006 HP aC++ v A.06.12 Edition 8 September 2007 HP aC++ v A.06.15 Edition 9 September 2008 HP aC++ v A.06.
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:1990. HP aC++ compiler supports the ISO/IEC 14882 Standard for the C++ Programming Language (the international standard for C++). Version A.06.
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 33) “CXXOPTS Environment Variable” (page 33) “CCLIBDIR Environment Variable” (page 34) “CCROOTDIR Environment Variable” (page 34) “TMPDIR Environment Variable” (page 34) aCC_FULL_PATHNAMES Environment Variable Exporting the aCC_FULL_PATHNAMES variable causes the compiler to include full path names for files in c
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. Syntax: export CCLIBDIR=directory setenv CCLIBDIR directory ksh/sh notation csh notation directory is an HP-UX directory where you want HP aC++ to look for libraries. Example: export CCLIBDIR=/mnt/proj/lib In this example HP aC++ searches the directory /mnt/proj/lib for libraries before searching the directory /opt/aCC/lib.
Syntax: export TMPDIR=directory setenv TMPDIR directory ksh/sh notation csh notation directory is the name of an HP-UX directory where you want HP aC++ to put temporary files during compilation. Example: export TMPDIR=/mnt/temp setenv TMPDIR /mnt/temp ksh notation csh notation The above example specifies that HP aC++ should put all temporary files in /mnt/ temp. Floating Installation More than one version of the HP aC++ compiler can be installed on one system at the same time.
Floating installation is designed to help facilitate in-house development. You must not ship libraries in non-standard places, because explicit runtime library specifications and linker options are required. You can use the __HP_cc predefined macro to determine which version is being run.
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 32).
• • “Verbose Compile and Link Information” (page 121) “Concatenating Options” (page 123) 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.
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. If you plan to run your program on a particular model of the HP-UX system, and that model is different from the one where you compile your program, use +DSmodel with either the model number of the target system or the processor name of the target system.
Table 2-2 Size and Alignment of HP Compiler Data Types (continued) Data Type Size (in bytes) Alignment 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 element type struct *** 1-, 2-, 4-, 8-, o
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. The primary use of this option is for compatibility with gcc, but it can provide performance improvement to applications that can accept the binary incompatibility. -unum +unum The +unum option allows pointers to access non-natively aligned data. This option alters the way that the compiler accesses dereferenced data.
-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. The difference is that the -g0 option emits full debug information about every class referenced in a file, which can result in some redundant information.
ref all none Emits debug information only for referenced macros. This is the default for -g, -g1, or -g0. Emits debug information for all macros. This option can cause a significant increase in object file size. 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. +[no]objdebug The +objdebug option generates debug information in object files and not in the executable.
The defined values for kind are: local global Generates a local path table and records basic block-execution information in it at runtime. Generates a global path table and records basic block-execution information in it at runtime. The global path table is a fixed size. The default size of the table is 8K items. Each basic block that is executed is recorded as an item of path-trace information in the table.
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. +pathtrace with no values is equivalent to +pathtrace=global_fixed_size:local. The use of this option and the -mt option must be consistent for all compilation and link steps.
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 and +wendian warnings. Those need to be enabled explicitly if needed. The default is to warn only about constructs that are almost certainly problems. For example, this option warns you when calls to inline functions cannot be expanded inline.
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. The default value for num is 5.
+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 double extended Evaluates floating-point expressions and constants in their semantic type. 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.
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. U (u) Trap on floating-point underflow.
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. For tuning purposes, it is recommended that users measure their application’s performance using a few different prefetch latency settings to determine the optimal value. Some floating-point codes may benefit by increasing the distance to 960.
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.
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. Specifying -I- serves two purposes: 1.
Angle-bracketed include files are searched for in dir1, then dir2, followed by the standard include directories. aCC -Idir1 -Idir2 -c a.C With view-pathing on, the following example searches for quoted include files in dir1 first and dir2 next, followed by the standard include directories, ignoring the directory of a.C. Angle-bracketed includes are searched for in dir2 first, followed by the standard include directories. aCC -Idir1 -I- -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 if it is installed on your system. -N -N The -N option causes the program file produced by the linker to be marked as unsharable. Unsharable executable files generated with the -N option cannot be executed with exec.
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 if it is installed on your system.
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.
+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.
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. If you still run out of memory, increase the per-process data size limit. Run the System Administrator Manager (SAM) to increase the maxdsiz_64bit process parameter to more than 4GB.
-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. The-ipo option will get implicitly invoked with the +O4 and +Ofaster options to match current behavior (+O4 ==> +O3 -ipo).
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.
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. The +Onolimit option suppresses optimizations regardless of their effect on compile time or memory consumption. Use +Onolimit at all optimization levels. Usage: +O[no]limit=level The defined values of level are: default min none Based on tuning heuristics, the optimizer will spend a reasonable amount of time processing large procedures.
+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. +O[no]ptrs_to_globals[=list] +O[no]ptrs_to_globals[=list] The +O[no]ptrs_to_globals option tells the optimizer whether global variables are accessed [are not accessed] through pointers.
The default, in the absence of +Oprofile=use, is +Onodatalayout. +O[no]dataprefetch +O[no]dataprefetch When +Odataprefetch is enabled, the optimizer inserts instructions within innermost loops to explicitly prefetch data from memory into the data cache. Data prefetch instructions are inserted only for data structures referenced within innermost loops using simple loop varying addresses (that is, in a simple arithmetic progression). Use this option for applications that have high data cache miss overhead.
If you specify neither +Ofltacc nor +Onofltacc, less optimization is performed than for +Onofltacc. If you specify neither option, the optimizer generates FMA instructions but does not perform any expression-reordering optimizations. Specifying +Ofltacc insures the same result as in unoptimized code (+O0).
The named functions are assumed to be frequently called. This option overrides any information in a profile database. +Ofrequently_called:filename The file indicated by filename contains a list of functions, separated by spaces or newlines. These functions are assumed to be frequently called. This option overrides any information in a profile database.
number leads it to consider more candidates. The inlining candidates are ordered in priority order based on the inliner’s heuristics, so this does not affect the most important candidates. The +Oinlinebudget option controls the aggressiveness of inlining according to the value you specify for n where n is an integer in the range 1 - 1000000 that specifies the level of aggressiveness, as follows: n= 100 n> 100 n<100 Default compile time budget.
+Ointeger_overflow +Ointeger_overflow=kind To provide the best runtime performance, the compiler makes assumptions that runtime integer arithmetic expressions that arise in certain contexts do not overflow (produce values that are too high or too low to represent) both expressions that are present in user code and expressions that the compiler constructs itself. Note that if an integer arithmetic overflow assumption is violated, runtime behavior is undefined.
Examples: • The following command optimizes all functions at level 3, except for the functions myfunc1 and myfunc2, which it optimizes at level 1. aCC +O3 +O1=myfunc1,myfunc2 funcs.c main.c • The following command optimizes all functions at level 2, except for the functions myfunc1 and myfunc2, which it optimizes at level 0. aCC -O +O0=myfunc1,myfunc2 funcs.c main.c +O[no]libcalls +O[no]libcalls The +O[no]libcalls option is deprecated and may not be supported in future releases.
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. +O[no]loop_unroll_jam +O[no]loop_unroll_jam Loop unroll-and-jam involves partially unrolling one or more loops higher in the nest than the innermost loop, and fusing ("jamming") the resulting loops back together.
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. You can add comments to the option file by using a "#" character in the first column of a line. The "#" causes the entire line to be ignored by the compiler.
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.
+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. NOTE: The program that uses signal handlers to catch signals raised by memory accesses may not behave correctly under +Onorecovery.
+Otype_safety +Otype_safety=kind The +Otype_safety option controls type-based aliasing assumptions. The defined values for kind are: off limited ansi strong The default. Specifies that aliasing can occur freely across types. Code follows ANSI aliasing rules. Unnamed objects should be treated as if they had an unknown type. Code follows ANSI aliasing rules. Unnamed objects should be treated the same as named objects.
NOTE: The +Ovolatile option is not recommended. Instead, use the C/C++ Standard volatile qualifiers. +O[no]whole_program_mode +O[no]whole_program_mode The +O[no]whole_program option enables the assertion that only those files that are compiled with this option directly reference any global variables and procedures that are defined in these files. In other words, this option asserts that there are no unseen accesses to the globals.
+Oprofile=use option (passing it the appropriate filename if necessary) to perform profile-based optimization. Example: aCC +Oprofile=collect -O -o prog.pbo prog.C The above command compiles prog.C with optimization, prepares the object code for data collection, and creates the executable file prog.pbo. Running prog.pbo collects runtime information in the file flow.data in preparation for optimization with +Oprofile=use.
Displaying Optimization Information The +O[no]info option displays informational messages about the optimization process. +O[no]info +O[no]info The +O[no]info option displays messages about the optimization process. This option may be helpful in understanding what optimizations are occurring. You can use the option at levels 0-4. The default is +Onoinfo at levels 0-4. Parallel Processing Options HP aC++ provides the following optimization options for parallel code.
Table 2-4 Option Matrix for -mt Libraries Flags old-lib -D_REENTRANT libstd 1.2.1 -DRW_MULTI_THREAD (-AP)& -DRWSTD_MULTI_THREAD librwtool 7.0.x -D_THREAD_SAFE -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE * -lpthread new-lib -D_REENTRANT (-AA) -D_RW_MULTI_THREAD libstd 2.2.1 -D_RWSTD_MULTI_THREAD -D_POSIX_C_SOURCE=199506L -D_HPUX_SOURCE * -lpthread C mode -D_REENTRANT -Ae/-Aa -D_POSIX_C_SOURCE=199506L -lpthread * required if -D_POSIX_C_SOURCE is used.
• _POSIX_C_SOURCE=199506L Required by pthread. • libpthread.* Kernel thread library used on 11.x systems See “Using Threads” (page 211) for more information. NOTE: Make sure that -mt is used consistently at compile and link times. When you link with -mt, everything must be compiled with -mt, even if you do not think your file will be used in a threaded application.
The +Oautopar option is supported when compiling C, C++, or Fortran files. Specifying +Oautopar implies the -mt option. The default is +Onoautopar, which disables automatic parallelization of loops. +O[no]report +O[no]report[=report_type] The +O[no]report option causes the compiler to display[not to display] various optimization reports.
+wlock +wlock The +wlock option enables compile-time diagnostic messages for potential errors in using lock/unlock calls in programs that use pthread-library-based lock/unlock functions. Warnings are emitted for acquiring an already acquired lock, releasing an already released lock, and unconditionally releasing a lock that has been conditionally acquired. This diagnostic checking is based on cross-module analysis performed by the compiler.
The +Ofast option selects a combination of optimization options for optimum execution speed for reasonable build times. Currently chosen options are: • • • • • • • • +O2 +Ofltacc=relaxed +Onolimit +DSnative +FPD -Wl,+pi,1M -Wl,+pd,1M -Wl,+mergeseg This option is a synonym for -fast. NOTE: Do not use this option for programs that depend on IEEE standard floating point denormalized numbers. Otherwise, different numerical results may occur. See +Ofltacc=relaxed.
itanium Tune for the Itanium® processor. itanium2 Tune for the Itanium2® processor. Tune for the processor on which the compiler is running. native Porting Options Use the following options as necessary when porting your code from other operating environments to HP-UX. -fast -fast The -fast option selects a combination of optimization options for optimum execution speed and reasonable build times.
The +ub option specifies unqualified char, short, int, long, and long long bitfields as unsigned. This option has no effect on signedness of enum bitfields or on signedness of non-bitfield char. The default is +sb. +uc +uc By default, all unqualified char data types are treated as signed char. Specifying +uc causes an unqualified (plain) char data type to be treated as unsigned char. (Overloading and mangling are unchanged.
This warning can be suppressed by not using a hex/octal constant: char a[4] = { 17, 0x22, 0x33, 0x44 }; // OK +wendian also warns of unions that make assumptions about data layout: union u1 { char c[4]; int v; }; union u2 { long long ll; short s[4]; char c[8]; }; This warning can be suppressed by adding a dummy member: union u1 { // OK char c[4]; int v; char dummy; }; Another type of warning is on the use of IO functions that read/write persistent data from files that may be endian-dependent: read(0, &i,
touch foo.c ; cc -E -dM foo.c -Dname -Dname[=def] name is the symbol name that is defined for the preprocessor. def is the definition of the symbol name (name). The -Dname option defines a symbol name (name) to the preprocessor, as if defined by the preprocessing directive#define. If no definition (def) is given, the name is defined as 1. NOTE: __ia64 and __HP_aCC are defined automatically. Example: The following example defines the preprocessor symbol DEBUGFLAG and gives it the value 1.
The +m[d] option directs a list of the quote 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 +m[d] when you also specify the -E or the -P option. When used with the -E option, only dependency information is generated.
-P -P Using the -P option only preprocesses the files named on the command line without invoking further phases. It leaves the result in corresponding files with the suffix .i. For example, the following command preprocesses the file prog.C leaving the output in the file prog.i. It does not compile the program. aCC -P prog.C -Uname -Uname name is the symbol name whose definition is removed from the preprocessor.
At compile time, the -p option produces code that counts the number of times each routine is called. At link-time, when you are building an executable (but not a shared library) -p picks up profiled versions of certain system libraries and picks up the prof support library. Example: The following example compiles file.C and creates the executable file a.out instrumented for use with prof. aCC -p file.C See the prof(1) manpage for more information.
The +check options need to be specified at both compile time and link time, since they may require additional libraries to be linked into the user program. If different +check options are specified while compiling different source files, all the specified +check options are needed at link time. Multiple +check options are interpreted left to right. In case of conflicting options, the one on the right will override an earlier +check option. NOTE: The +check option is only supported on Integrity servers.
• • all - Enables out-of-bounds checks for both arrays and pointers. This is equal to +check=bounds:array +check=bounds:pointer. none - Disables out-of-bounds checks. +check=bounds (with no suboption) is equal to +check=bounds:array. This may change in the future to also include +check=bounds:pointer. When +check=all is specified, it enables +check=bounds:array only. To enable the pointer out-of-bounds check, you must explicitly specify +check=bounds:pointer.
34 35 36 37 i, lp[i], i+1, ip[i+1], j, ip[j]); return 0; } Compiling with +check=bounds:pointer: $ cc +check=bounds:pointer rttest3.c "rttest3.c", line 34: warning #2549-D: variable "j" is used before its value is set i, lp[i], i+1, ip[i+1], j, ip[j]); ^ Catch out-of-bounds pointer access through an uninitialized variable (the uninitialized variable can be checked by +check=uninit): $ RTC_NO_ABORT=1 a.
(variable "a"), reading at 0x40010320+44, 4 bytes ("rttest3.c", line 33) (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) 0x00000000040038f0 main + 0x300 at rttest3.c:33 [./a.out] (3) 0x60000000c0049c50 main_opd_entry + 0x50 [/usr/lib/hpux32/dld.so] Runtime Error: out of bounds buffer pointed by 0x40010320 has 40 bytes (variable "a"), reading at 0x40010320-19824, 4 bytes ("rttest3.
+check=lock The +check=lock option enables checking of C and C++ user applications that use pthreads. The option reports violations of locking discipline when appropriate locks are not held while accessing shared data by different threads. The check is based on the lockset method for detecting locking discipline violations, as described in the Eraser tool article at http://citeseerx.ist.psu.edu/viewdoc/ download?doi=10.1.1.22.3256&rep=rep1&type=pdf. Note that +check=all does not enable +check=lock.
at /ux/core/libs/threadslibs/src/common/pthreads/pthread.c:4512 [/proj/thlo/Compilers/rt/usr/lib/hpux32/libpthread.so.1] candidate lockset is as follows: lock1.c line number:23 incoming lockset is as follows: lock1.c line number:13 In the above message, the candidate lockset refers to the set of locks that are implied to be associated with the symbol acesss in its previous accesses so far. The incoming lockset refers to the set of locks that are held at the current access of the symbol.
When +check=bounds:pointer is also turned on, it can check freed memory read/write. But the check needs to retain freed memory which is not turned on by default. To turn on the feature, set the following environment variable at runtime: RTC_MALLOC_CONFIG="retain_freed_blocks=1" Or add "retain_freed_blocks=1" to the rtcconfig file. When malloc failes to allocate specified memory, the runtime system will free the retained freed memory and try to allocate memory.
• • • • • • • • The thread attempts to acquire a nonrecursive mutex that it currently holds. The thread attempts to unlock a mutex or a read-write lock that it has not acquired. The thread waits (blocked) on a mutex or read-write lock that is held by a thread with a different scheduling policy. Different threads non-concurrently wait on the same condition variable, but with different associated mutexes. The threads terminate execution without unlocking the associated mutexes or read-write locks.
Note that the +check=all option does not imply +check=truncate. To enable +check=truncate, you must explicitly specify it. +check=truncate:explicit This option turns on runtime checks for truncation on explicit user casts of integral values, such as (char)int_val. +check=truncate:implicit This option turns on runtime checks for truncation on compiler-generated implicit type conversions, such as ch = int_val;.
The -Aa option instructs the compiler to use Koenig lookup and strict ANSI for scope rules. This option is equivalent to specifying -Wc,-koenig_lookup,on and -Wc,-ansi_for_scope,on. The default is off. Refer to -Ae option for C-mode description. The standard features enabled by -Aa are incompatible with earlier C and C++ features. -AA -AA The -AA option enables the use of the new 2.0 Standard C++ Library, which includes the new standard conforming (templatized) iostream library.
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. For more information on the ARM dialect, refer to the The Annotated C++ Reference Manual, (Margaret A. Ellis and Bjarne Stroustrup, Addison-Wesley, ISBN 0-201-51459-1, 1990). -AC89 -AC89 The -AC89 option invokes the compiler in ANSI C89 compilation mode. This option, when specified with -ext option, invokes a part of ANSI C99 features.
NOTE: For HP aC++, the -Ae option must also be used. -AOa and -AOe -AOa -AOe See the following C mode options: • • “-Aa” (page 108) “-Ae” (page 110) In addition to specifying the ANSI C language dialect, allows the optimizer to aggressively exploit the assumption that the source code conforms to the ANSI programming language C standard ISO 9899:1990. At present, the effect is to make +Otype_safety=ansi the default.
This option causes return types of unprototyped functions to be treated as long, instead of int, matching Tru64 C behavior. This can prevent segfaults in +DD64 mode, resulting from pointer truncation, for instance: long *a; long sub() { a = malloc(sizeof(long)); *a = 1234; return *a; } /* no prototype! */ /* segfault if +DD64 and no +tru64 */ A preferable solution is to provide the appropriate function prototypes. NOTE: This option is applicable to C language only.
-Wc,-koenig_lookup,[on|off] -Wc,-koenig_lookup,[on|off] The -WC,-koenig_lookup option enables or disables standard argument-dependent lookup rules (also known as Koenig lookup). It causes functions to be looked up in the namespaces and classes associated with the types of the function-call argument. By default, the option is enabled. Example: In the following example, if the option is not enabled, the call in main does not consider declaration (1) and selects (2).
Table 2-7 Identifiers (continued) x Description p Preprocessor (standard suffix is cpp.ansi). -tp must be used before any -Wp options can be passed to cpp.ansi. To enable the external preprocessor, use: -tp,/opt/langtools/lbin/cpp.ansi. u Stand-alone code generator (standard suffix is u2comp) x All subprocesses The -tx,name option works in two modes: 1. 2. If x is a single identifier, name represents the full path name of the new subprocess.
The -Wx,args option passes the arguments arg1 through argn to the subprocess x of the compilation. Each argument, arg1, arg2, through argn takes the form: -argoption[,argvalue] where: • • argoption is the name of an option recognized by the subprocess. argvalue is a separate argument to argoption, where necessary. The parameter, x, is one or more identifiers indicating a subprocess or subprocesses.
aCC -Wl,-a,archive,-m,-v file.o -lm This case is similar to the previous example, with additional options. -m indicates that a load map should be produced. The -v option requests verbose messages from the linker. Symbol Binding Options The following -B options are recognized by the compiler to specify whether references to global symbols may be resolved to symbols defined in the current load module, or whether they must be assumed to be potentially resolved to symbols defined in another load module.
Usage: -Bextern=symbol[,symbol...] The named symbols, or all symbols if no list is provided, are assigned the default export class. Use of list form overrides the default binding of locally defined symbols. -Bextern:filename The file indicated by filename is expected to contain a list of symbols, separated by spaces or newlines. These symbols are assigned the default export class. -Bhidden -Bhidden The specified symbols, or all symbols if no symbols are specified, are assigned the hidden export class.
When used with no symbol list, -Bprotected implies -Wl,-aarchive_shared, causing the linker to prefer an archive library over a shared library, if one is available. This can be overridden by following the -Bprotected option with a subsequent -Wl,-a option. Usage: -Bprotected:filename The file indicated by filename contains a list of symbols, separated by spaces or newlines. These symbols are assigned the protected export class.
NOTE: All template options on an aCC command line apply to every file on the command line. If you specify more than one incompatible option on a command line, only the last option takes effect. +[no]dep_name The +[no]dep_name option enforces strict dependent-name lookup rules in templates. The default is +dep_name. +inst_compiletime +inst_compiletime The +inst_compiletime option causes the compiler to use the compile time (CTTI) instantiation mechanism to instantiate templates.
This option is strongly discouraged and the sources should be modified to conform to the standard. Example: aCC +inst_implicit_include prog.C If prog.C includes a template declaration file named template.h, the compiler assumes a template definition file name determined by the +inst_include_suffixes option. See Chapter 5: “Using HP aC++ Templates” (page 169) for more information. NOTE: This option is supported in C++ only and ignored in C-mode.
NOTE: This option is supported in C++ only and ignored in C-mode. Trigraph Processing Suppression Option The -notrigraphoption suppresses trigraph processing. -notrigraph The-notrigraph option inhibits the processing of trigraphs. In previous versions, [LINEBREAK]-notrigraph caused the legacy preprocessor to be invoked. Though this ignored trigraphs, trigraphs were still interpreted by the compiler in the preprocessed source.
+O[no]info +O[no]info The +Oinfo option displays informational messages about the optimization process. This option may be helpful in understanding what optimizations are occurring. You can use the option at levels 0-4. The default is +Onoinfo at levels 0-4. +wsecurity +wsecurity[={1|2|3|4}] The +wsecurity option can take an argument to control how verbosely the security messages are emitted. The default level is 2. +time +time The +time option generates timing information for compiler subprocesses.
-v -v The -v option enables verbose mode, sending a step-by-step description of the compilation process to stderr. This option is especially useful for debugging or for learning the appropriate commands for processing a C++ file. Example: The aCC -v file.C command compiles file.C and gives information about the process of compiling.
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 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_GLOBALSname 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..
STDC FP_CONTRACT Pragma #pragma STDC FP_CONTRACT ON #pragma STDC FP_CONTRACT OFF This pragma tells the compiler whether or not it is permitted to contract expressions. Also see ISO/IEC 9899 Standard. Each pragma can occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement. When outside external declarations, the pragma takes effect from its occurrence until another FP_CONTRACT pragma is encountered, or until the end of the translation unit.
#pragma UNROLL (n) This block-scoped pragma applies the unroll factor for a loop containing the current block. You can apply an unroll factor that you think is best for the given loop or apply no unroll factor to the loop. If this pragma is not specified, the compiler uses its own heuristics to determine the best unroll factor for the inner loop. A user specified unroll factor will override the default unroll factor applied by the compiler. Specifying n=1 will prevent the compiler from unrolling the loop.
OMP CRITICAL Pragma #pragma omp critical [(name)] structured-block The critical pragma identifies a construct that restricts the execution of the associated structured block to one thread at a time. The name parameter is optional. All unnamed critical sections map to the same name. OMP FOR Pragma #pragma omp for [clause1,clause2, ...] for-loop where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.
NOTE: The directive is not implied if a nowait clause is present. OMP MASTER Pragma #pragma omp master structured-block The master pragma directs that the structured-block following it should be executed by the master thread (thread 0) of the team. Other threads in the team do not execute the associated block.
OMP PARALLEL FOR Pragma #pragma omp parallel for [clause1, clause2, ... ] for-loop where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses. The parallel for pragma is a shortcut for a parallel region that contains a single for pragma. parallel for admits all the allowable clauses of the parallel pragma and the for pragma except for the nowait caluse. OMP PARALLEL SECTIONS Pragma #pragma omp parallel sections [clause1, clause2, ...
The section or sections pragmas identify a construct that specifies a set of constructs to be divided among threads in a team. Each section is executed by one of the threads in the team. OMP SINGLE Pragma #pragma omp single [clause1, clause2, . . .] [ structured-block ] where [clause1, clause2, ...] indicates that the clauses are optional. There can be zero or more clauses.
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.
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. Example #pragma OPTIMIZE ON See for more information on pragmas. Error Directive (#error) The #error directive causes a diagnostic message, along with any included token arguments, to be produced by HP aC++.
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. A trigraph sequence is a set of three characters that is replaced by a corresponding single character. The preprocessor replaces all trigraph sequences with the corresponding character.
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.
void 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”)); } void 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. } void 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.
aCC +Oprofile=use -O sample.C -o sample.exe // Recompile with optimization. • • • • Numerical applications which perform the same calculations independent of the input data will only see a small performance boost. Profile-based optimization has the greatest impact on application performance when used with level 2 or greater optimizations.
The first line creates an intermediate file for instrumentation. The second line creates optimized code with instrumentation. Collecting Data for Profiling To collect execution profile statistics, run your instrumented program with representative data as follows: sample.exe < input.file1 sample.exe < input.file2 This step creates and logs the profile statistics to a file, by default called flow.data.
aCC -o sample.exe +Oprofile=use sample.o When optimizing at level 4, (where code generation is delayed until link time), use the +Oprofile=use option as follows: aCC +Oprofile=use +O4 x.o y.o When +Oprofile=use is used, no recompilation is necessary. The .o file saved from the instrumentation phase can be used as input. For more information on profile-based optimization, you can refer to the HP-UX Online Linker and Libraries User’s Guide.
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 227) • “Creating and Using Libraries” (page 228) • “HP aC++ File Locations” (page 242) 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 256).
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 261) • “Obsolete Command-Line Options” (page 261) • “Changed Command-Line Options” (page 263) 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 37) 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 281) “Ambiguous Function or Object Declaration” (page 281) “Overloaded Operations ++ and --” (page 282) “Reference Initialization” (page 282) “Using operator new to Allocate Arrays” (page 283) “Parentheses in Static Member Initialization List” (page 283) “&qualified-id Required in Static Member Initialization List” (page 284) “Non-constant Reference Initialization” (page 284) “Digraph White Space Separators” (page 285) 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 169) 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 289) • “Frequently Encountered Messages” (page 290) 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, 157 ## operator, 157 -unum, 42 .
+Oinlinebudget, 76 +Ointeger_overflow, 78 +Olevel, 78 +Olit, 77 +Onolibcalls, 62 +Oprefetch_latency, 53 +Oprofile, 85 +opts, 81 +Orarely_called, 82 +Oshortdata, 83 +Otype_safety, 84 +Ounroll_factor, 84 +p, 46 +pathtrace, 44 +profilebucketsize, 99 +sb, 93 +time, 122 +tls=[static|dynamic], 90 +tru64, 111 +ub, 93 +uc, 94 +w, 47 +w64bit, 94 +Wargs, 47 +Wcontext_limit, 47 +We, 48 +Weargs, 48 +wendian, 94 +wlint, 49 +wlock, 91 +Wmacro, 49 +wn, 47 +wperfadvice, 49 +wsecurity, 49, 122 +Wv, 48 +Wwargs, 48 -.
containers, 239 CROOTDIR, 34 CXXOPTS, 33 D #define, 155 E #endif, 162 environment variable, 33 environment variables in OpenMP, 219 exception handling, 209 ANSI/ISO C++ Intl. Std.
NO_INLINE, 136 NO_RETURN, 136 NODEPCHK, 136 OMP ATOMIC, 143 OMP BARRIER, 143 OMP CRITICAL, 144 OMP FLUSH, 144 OMP FOR, 144 OMP MASTER, 145 OMP ORDERED, 145 OMP PARALLEL, 145 OMP PARALLEL FOR, 146 OMP PARALLEL SECTIONS, 146 OMP SECTIONS, 146 OMP SINGLE, 147 OMP THREADPRIVATE, 147 OPT_LEVEL, 133 OPTIMIZE, 134 PACK, 128 POP, 140 PROTECTED, 140 PTRS_STRONGLY_TYPED, 140 PUSH, 141 RARELY_CALLED, 141 STDC CX_LIMITED_RANGE, 141 STDC FENV_ACCESS, 142 STDC FP_CONTRACT, 142 UNALIGN, 133 UNROLL_FACTOR, 142 VERSION_ID,