VisualAge C++ for AIX Compiler Reference
SC09-4959-00
VisualAge C++ for AIX Compiler Reference
SC09-4959-00 Before using this information and the product it supports, be sure to read the information in “Notices” on page 411.
May 2002 Edition This edition applies to Version 6 Release 0 of VisualAge C++ Professional for AIX (product number 5765–F56) and to all subsequent releases and modifications until otherwise indicated in new editions. IBM® welcomes your comments. You can send them by either of the following methods: v Internet: compinfo@ca.ibm.com Be sure to include your e-mail address if you want a reply. v By mail to the following address: IBM Canada Ltd. Laboratory Information Development B3/KB7/8200/MKM 8200 Warden Avenue Markham, Ontario, Canada L6G 1C7 Include the title and order number of this book, and the page number or topic related to your comment. When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 1995,2002. All rights reserved. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents
How to read syntax diagrams .....vii Specify Compiler Options for Architecture-Specific, Symbols...... vii 32-or64-bitCompilation...... 29 Syntax items ...... vii Resolving Conflicting Compiler Options .....31 Syntax examples ...... viii Specify Path Names for Include Files 33 Part 1. Concepts ...... 1 Directory Search Sequence for Include Files Using RelativePathNames...... 33 VisualAge C++ Compiler ...... 3 Structure a Program that Uses Compiler Modes ...... 3 Object Models ...... 4 Templates ...... 35 Compiler Options...... 5 Declaration of Stack in stack.h ...... 35 Types of Input Files ...... 6 Declaration of operator Functions in stack.c . . . 35 Types of Output Files ...... 7 Template Functions Declared Inline and Template Compiler Message and Listing Information ....8 Functions With Internal Linkage ...... 36 Compiler Messages ...... 8 Template Functions Defined within the Compilation Compiler Listings...... 8 Unit...... 37 Use -qtempinc to Generate Template Functions Program Parallelization ...... 9 Automatically ...... 38 How the Compiler Generates the Function IBM SMP Directives ...... 9 Definitions...... 39 OpenMP Directives ...... 10 Specifying the Template-Implementation File . . 40 Countable Loops ...... 11 Specifying a Different Path for the tempinc Reduction Operations in Parallelized Loops . . . 12 Subdirectory ...... 40 Shared and Private Variables in a Parallel Regenerating the Template Instantiation File . . 40 Environment ...... 13 Breaking a Template Instantiation File into More Than One File ...... 40 Using VisualAge C++ with Other ContentsofTemplateInstantiationFile....40 Programming Languages...... 15 Using #pragma Directives in Header Files . . . 41 Considerations for Shared Libraries .....42 Part 2. Tasks ...... 17 Use -qnotempinc to Define Template Functions . . 42 Use -qtemplateregistry to Define Template Functions 43 Recompiling Parts of Your Program After Making Set Up the Compilation Environment 19 Source Changes ...... 43 Set Environment Variables ...... 19 Set Environment Variables in bsh, ksh, or sh Control Parallel Processing with Shells ...... 19 Pragmas ...... 45 Set Environment Variables in csh Shell ....19 Set Environment Variables to Select 64- or 32-bit Modes...... 20 Use C and C++ with Other Set Parallel Processing Run-time Options ....20 Programming Languages...... 47 Set Environment Variables for the Message and Interlanguage Calling Conventions ...... 47 Help Files ...... 20 Corresponding Data Types ...... 47 Special Treatment of Character and Aggregate Invoke the Compiler ...... 23 Data...... 48 Invoke the Linkage Editor ...... 23 Use the Subroutine Linkage Conventions in Interlanguage Calls ...... 49 Specify Compiler Options ...... 25 Interlanguage Calls - Parameter Passing ....50 Interlanguage Calls - Call by Reference Specify Compiler Options on the Command Line. . 25 Parameters ...... 51 -qOptions...... 25 Interlanguage Calls - Call by Value Parameters 52 FlagOptions...... 26 Interlanguage Calls - Rules for Passing Specify Compiler Options in Your Program Source Parameters by Value ...... 52 Files ...... 27 Interlanguage Calls - Pointers to Functions . . . 54 Specify Compiler Options in a Configuration File. . 27 Interlanguage Calls - Function Return Values . . 54 TailoraConfigurationFile...... 28 Interlanguage Calls - Stack Floor ...... 55 Configuration File Attributes ...... 28
© Copyright IBM Corp. 1995,2002 iii Interlanguage Calls - Stack Overflow .....55 haltonmsg...... 144 Interlanguage Calls - Traceback Table.....56 heapdebug ...... 145 Interlanguage Calls - Type Encoding and hot...... 146 Checking...... 56 hsflt ...... 148 Sample Program: C Calling Fortran ...... 57 hssngl...... 149 I...... 150 Part 3. Reference ...... 59 idirfirst ...... 151 ignerrno ...... 152 ignprag ...... 153 Compiler Options ...... 61 info...... 154 Compiler Command Line Options ...... 61 initauto...... 157 +(plussign)...... 71 inlglue...... 158 # (pound sign) ...... 72 inline...... 159 32,64...... 73 ipa...... 163 aggrcopy ...... 74 isolated_call...... 170 alias...... 75 keepinlines...... 171 align...... 77 keyword...... 172 alloca...... 81 L...... 173 ansialias...... 82 l...... 174 arch...... 83 langlvl...... 175 assert ...... 86 largepage...... 189 attr...... 87 ldbl128, longdouble ...... 190 B...... 88 libansi ...... 191 b...... 89 linedebug...... 192 bitfields ...... 90 list ...... 193 bmaxdata ...... 91 listopt ...... 194 brtl...... 92 longlit...... 195 C...... 93 longlong ...... 197 c...... 94 M...... 198 cache...... 95 ma...... 199 chars...... 97 macpstr...... 200 check...... 98 maf...... 203 cinc...... 100 makedep...... 204 compact...... 101 maxerr...... 206 cpluscmt...... 102 maxmem...... 208 D...... 106 mbcs,dbcs...... 209 dataimported ...... 108 mkshrobj...... 210 datalocal...... 109 namemangling...... 214 dbxextra ...... 110 O,optimize...... 215 digraph...... 111 o...... 219 dollar...... 113 objmodel...... 220 dpcl...... 114 oldpassbyvalue ...... 221 E...... 115 P...... 222 e ...... 117 p...... 223 eh...... 118 pascal...... 224 enum...... 119 path...... 225 expfile...... 125 pdf1,pdf2...... 226 extchk...... 126 pg...... 229 F...... 127 phsinfo...... 230 f...... 128 print...... 231 fdpr...... 129 priority ...... 232 flag...... 130 proclocal, procimported, procunknown ....233 float...... 131 proto...... 235 flttrap ...... 135 Q...... 236 fold...... 137 r...... 239 fullpath...... 138 report...... 240 funcsect ...... 139 rndflt...... 241 G...... 140 rndsngl...... 243 g...... 141 ro...... 244 genproto...... 142 roconst...... 245 halt...... 143 rrm...... 246 iv VisualAge C++ for AIX Compiler Reference rtti ...... 247 #pragma langlvl ...... 317 S ...... 248 #pragma leaves...... 318 s ...... 249 #pragmamap...... 319 showinc...... 250 #pragmamc_func...... 321 smallstack ...... 251 #pragmanamemangling...... 322 smp...... 252 #pragma nameManglingRule ...... 323 source...... 254 #pragma object_model ...... 324 spill...... 255 #pragmaoptions...... 325 spnans ...... 256 #pragma option_override ...... 331 srcmsg...... 257 #pragmapack...... 332 staticinline ...... 258 #pragma pass_by_value ...... 335 statsym...... 259 #pragma priority ...... 336 stdinc...... 260 #pragma reachable ...... 337 strict ...... 261 #pragma reg_killed_by ...... 338 strict_induction...... 262 #pragmareport...... 339 suppress ...... 263 #pragma strings ...... 341 symtab...... 264 #pragmaunroll...... 342 syntaxonly ...... 265 Pragmas to Control Parallel Processing .....344 t...... 266 #pragma ibm critical ...... 346 tabsize...... 267 #pragmaibmindependent_calls...... 347 tbtable...... 268 #pragmaibmindependent_loop...... 348 tempinc...... 269 #pragma ibm iterations ...... 349 templaterecompile...... 270 #pragma ibm parallel_loop ...... 350 templateregistry ...... 271 #pragmaibmpermutation...... 351 tempmax...... 272 #pragmaibmschedule...... 352 threaded...... 273 #pragmaibmsequential_loop...... 354 tmplparse...... 274 #pragmaompatomic...... 355 tocdata...... 275 #pragma omp parallel ...... 356 tocmerge...... 276 #pragmaompfor...... 358 tune...... 277 #pragmaompordered...... 362 twolink...... 279 #pragma omp parallel for ...... 363 U...... 281 #pragma omp section, #pragma omp sections 364 unique...... 282 #pragma omp parallel sections ...... 366 unroll...... 283 #pragmaompsingle...... 367 unwind...... 285 #pragma omp master...... 368 upconv...... 286 #pragma omp critical ...... 369 V...... 287 #pragma omp barrier...... 370 v...... 288 #pragmaompflush...... 371 vftable...... 289 #pragmaompthreadprivate...... 372 W...... 290 Acceptable Compiler Mode and Processor w...... 291 Architecture Combinations ...... 373 warn64...... 292 xcall...... 293 Compiler Messages...... 379 xref...... 294 Message Severity Levels and Compiler Response 379 y...... 295 Compiler Return Codes ...... 379 Z...... 296 Compiler Message Format ...... 380 GeneralPurposePragmas...... 297 #pragmaalign...... 299 Parallel Processing Support .....383 #pragmaalloca...... 300 IBM SMP Run-time Options for Parallel Processing 383 #pragmachars...... 301 Scheduling Algorithm Options ...... 383 #pragmacomment...... 302 Parallel Environment Options ...... 384 #pragma define...... 303 Performance Tuning Options ...... 384 #pragma disjoint ...... 304 Dynamic Profiling Options ...... 385 #pragmaenum...... 305 OpenMP Run-time Options for Parallel Processing 386 #pragma execution_frequency ...... 306 Scheduling Algorithm Environment Variable 386 #pragmahashome...... 308 Parallel Environment Environment Variables 387 #pragma ibm snapshot ...... 309 Dynamic Profiling Environment Variable . . . 387 #pragmaimplementation...... 310 Built-in Functions Used for Parallel Processing . . 388 #pragmainfo...... 311 #pragmaishome...... 314 #pragmaisolated_call...... 315 Part 4. Appendixes ...... 391
Contents v Appendix A. Built-in Functions ....393 Restrictions ...... 403 General Purpose Built-in Functions ...... 393 LIBANSI Built-in Functions...... 394 Appendix C. Problem Solving ....405 Built-in Functions for PowerPC Processors . . . 394 MessageCatalogErrors...... 405 Correcting Paging Space Errors During Appendix B. National Languages Compilation...... 405 Support in VisualAge C++ ...... 401 Converting Files Containing Multibyte Data to Appendix D. ASCII Character Set . . . 407 New Code Pages ...... 401 Multibyte Character Support ...... 401 Notices ...... 411 String Literals and Character Constants . . . 401 Programming Interface Information ...... 413 Preprocessor Directives ...... 402 TrademarksandServiceMarks...... 413 Macro Definitions ...... 402 Industry Standards ...... 413 Compiler Options ...... 402 FileNamesandComments...... 403
vi VisualAge C++ for AIX Compiler Reference How to read syntax diagrams
This section describes how to read syntax diagrams. It defines syntax diagram symbols, items that may be contained within the diagrams (keywords, variables, delimiters, operators, fragment references, operands) and provides syntax examples that contain these items.
Syntax diagrams pictorially display the order and parts (options and arguments) that comprise a command statement. They are read from left to right and from top to bottom, following the main path of the horizontal line.
Symbols The following symbols may be displayed in syntax diagrams: Symbol Definition ─── Indicates the beginning of the syntax diagram. ─── Indicates that the syntax diagram is continued to the next line. ─── Indicates that the syntax is continued from the previous line. ─── Indicates the end of the syntax diagram.
Syntax items Syntax diagrams contain many different items. Syntax items include: v Keywords - a command name or any other literal information. v Variables - variables are italicized, appear in lowercase and represent the name of values you can supply. v Delimiters - delimiters indicate the start or end of keywords, variables, or operators. For example, a left parenthesis is a delimiter. v Operators - operators include add (+), subtract (-), multiply (*), divide (/), equal (=), and other mathematical operations that may need to be performed. v Fragment references - a part of a syntax diagram, separated from the diagram to show greater detail. v Separators - a separator separates keywords, variables or operators. For example, a comma (,) is a separator.
Keywords, variables, and operators may be displayed as required, optional, or default. Fragments, separators, and delimiters may be displayed as required or optional. Item type Definition Required Required items are displayed on the main path of the horizontal line. Optional Optional items are displayed below the main path of the horizontal line. Default Default items are displayed above the main path of the horizontal line.
© Copyright IBM Corp. 1995,2002 vii Syntax examples The following table provides syntax examples. Table 1. Syntax examples Item Syntax example Required item. KEYWORD required_item Required items appear on the main path of the horizontal line. You must specify these items. Required choice. KEYWORD required_choice1 A required choice (two or more items) appears in a required_choice2 vertical stack on the main path of the horizontal line. You must choose one of the items in the stack. Optional item. KEYWORD Optional items appear below the main path of the optional_item horizontal line.
Optional choice. KEYWORD A optional choice (two or more items) appear in a vertical optional_choice1 stack below the main path of the horizontal line. You may optional_choice2 choose one of the items in the stack.
Default. default_choice1 Default items appear above the main path of the KEYWORD horizontal line. The remaining items (required or optional_choice2 optional) appear on (required) or below (optional) the optional_choice3 main path of the horizontal line. The following example displays a default with optional items. Variable.
Variables appear in lowercase italics. They represent KEYWORD variable names or values.
viii VisualAge C++ for AIX Compiler Reference Table 1. Syntax examples (continued) Item Syntax example Repeatable item.
An arrow returning to the left above the main path of the horizontal line indicates an item that can be repeated. KEYWORD repeatable_item
An arrow returning to the left above a group of repeatable items indicates that one of the items can be selected, or a single item can be repeated. Fragment. KEYWORD fragment The ─┤ fragment ├─ symbol indicates that a labelled group is described below the main syntax diagram. fragment: Syntax is occasionally broken into fragments if the inclusion of the fragment would overly complicate the ,required_choice1 main syntax diagram. ,default_choice ,required_choice2 ,optional_choice
How to read syntax diagrams ix x VisualAge C++ for AIX Compiler Reference Part 1. Concepts
© Copyright IBM Corp. 1995,2002 1 2 VisualAge C++ for AIX Compiler Reference VisualAge C++ Compiler
You can use IBM VisualAge C++ as a C compiler for files with a .c (small c) suffix, or as a C++ compiler for files with a .C (capital C), .cc, .cpp, or .cxx suffix. The compiler processes your program source files to create an executable object module.
Note: Throughout these pages, the xlC command invocation is used to describe the actions of the compiler. You can, however, substitute other forms of the compiler invocation command if your particular environment requires it, and compiler option usage will remain the same unless otherwise specified.
For more information about the VisualAge C++ compiler, see the following topics in this section: v “Compiler Modes” v “Object Models” on page 4 v “Compiler Options” on page 5 v “Types of Input Files” on page 6 v “Types of Output Files” on page 7 v “Compiler Message and Listing Information” on page 8
Compiler Modes Several forms of VisualAge C++ compiler invocation commands support various version levels of the C and C++ languages. In most cases, you should use the xlC command to compile your C++ source files, and the xlc command to compile C source files. Use the xlC command when you have both C and C++ source files..
You can, however, use other forms of the command if your particular environment and file systems require it. The various compiler invocation commands are: xlC xlC128 xlC_r xlC128_r xlC_r4 xlC128_r4 xlC_r7 xlC128_r7 xlc xlc128 xlc_r xlc_r4 xlc_r7 cc cc128 cc_r cc_r4 cc_r7 c89
The four basic compiler invocation commands appear as the first entry of each line in the table above. Select a basic invocation using the following criteria:
xlC Invokes the compiler so that source files are compiled as C++ language source code.
Files with .c suffixes, assuming you have not used the -+ compiler option, are compiled as C language source code with a default language level of ansi, and compiler option -qansialias to allow type-based aliasing.
If any of your source files are C++, you must use this invocation to link with the correct runtime libraries. xlc Invokes the compiler for C source files with a default language level of ansi, and compiler option -qansialias to allow type-based aliasing.
© Copyright IBM Corp. 1995,2002 3 cc Invokes the compiler for C source files with a default language level of extended and compiler options -qnoro and -qnoroconst (to provide compatibility with the RT compiler and placement of string literals or constant values in read/write storage). Use this invocation for legacy C code that does not require compliance with ANSI C. c89 Invokes the compiler for C source files, with a default language level of ansi, and specifies compiler options -qansialias (to allow type based aliasing) and -qnolonglong (disabling use of long long), and sets -D_ANSI_C_SOURCE (for ANSI-conformant headers). Use this invocation for strict conformance to the ANSI standard (ISO/IEC 9899:1990).
IBM VisualAge C++ provides variations on the four basic compiler invocations. These variations are described below:
128-suffixed All 128-suffixed invocation commands are functionally similar to their Invocations corresponding base compiler invocations. They specify the -qldbl128 option, which increases the length of long double types in your program from 64 to 128 bits. They also link with the 128 versions of the C and C++ runtimes. _r-suffixed All _r-suffixed invocations additionally set the macro names Invocations -D_THREAD_SAFE and add the libraries -L/usr/lib/threads, -lc and -lpthreads. The compiler option -qthreaded is also added. Use these commands if you want to create Posix threaded applications.
AIX 4.1 and 4.2 support Posix Draft 7. AIX 4.3 supports Draft 10. The _r7 invocations are provided on AIX 4.3 to help with migration to Draft 10. See -qthreaded for additional information. The _r4 invocations should be used for DCE threaded applications.
Migrating AIX Version 3.2.5 DCE Applications to AIX Version 4.3.3 and higher
The main invocation commands (except c89) have additional _r4-suffixed forms. These forms provide compatibility between DCE applications written for AIX Version 3.2.5 and AIX Version 4. They link your application to the correct AIX Version 4 DCE libraries, providing compatibility between the latest version of the pthreads library and the earlier versions supported on AIX Version 3.2.5. Related Tasks “Invoke the Compiler” on page 23 Related References “Compiler Command Line Options” on page 61 “General Purpose Pragmas” on page 297 “Pragmas to Control Parallel Processing” on page 344 “threaded” on page 273
Object Models VisualAge C++ lets you compile your program to either of two object models. The two object models are: v compat v ibm
The two object models differ in the following areas: v Layout for the virtual function table v Virtual base class support
4 VisualAge C++ for AIX Compiler Reference v Name mangling scheme
Select compat if you need your runtime module to be compatible with any runtime modules compiled with the compat object module or with previous versions of VisualAge C++.
Select ibm if you want improved performance. This is especially true for class hierarchies with many virtual base classes. The size of the derived class is considerably smaller and access to the virtual function table is faster.
All classes in the same inheritance hierarchy must have the same object model.
Use the -qobjmodel compiler option or the object_model pragma to specify a target object model. Related References “objmodel” on page 220 “#pragma object_model” on page 324
Compiler Options Compiler options perform a wide variety of functions, such as setting compiler characteristics, describing the object code and compiler output to be produced, and performing some preprocessor functions. You can specify compiler options in one or more of three ways: v on the command line v in a configuration file (.cfg) v in your source program
The compiler assumes default settings for most compiler options not explicitly set by you in the ways listed above.
When specifying compiler options, it is possible for option conflicts and incompatibilities to occur. IBM VisualAge C++ resolves most of these conflicts and incompatibilities in a consistent fashion, as follows:
Compiler options priority sequence