Note!
Before using this information and the product it supports, be sure to read the general
information under Notices on page v.
Edition Notice
This edition applies to Version 5.0 of IBM VisualAge C++ and to all subsequent releases and modifications until
otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product.
Copyright International Business Machines Corporation 1998, 2000. All rights reserved.
US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract
with IBM Corp.
Contents
Notices . . . . . . . . . . . . . . . v
Programming Interface Information . . . . . . vii
Trademarks and Service Marks . . . . . . . . vii
Industry Standards . . . . . . . . . . . viii
align (AIX) . .
alloca (C, AIX)
chars . . . .
comment . .
define (C++) .
disjoint . . .
entry . . . .
enum . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
5
6
6
7
8
9
9
#pragma export . . . . . . . . .
#pragma hdrfile (C). . . . . . . .
Examples using #pragma hdrfile (C) .
#pragma hdrstop (C) . . . . . . .
Examples using #pragma hdrstop (C).
#pragma import . . . . . . . . .
#pragma info . . . . . . . . . .
Example: #pragma isolated_call. . .
#pragma langlvl (C) . . . . . . .
#pragma leaves . . . . . . . . .
#pragma map . . . . . . . . .
#pragma namemangling (C++) . . . .
#pragma object_model (C++) . . . .
#pragma options (AIX) . . . . . .
#pragma priority (C++) . . . . . .
#pragma reachable . . . . . . . .
#pragma report (C++) . . . . . . .
#pragma strings . . . . . . . . .
Contacting IBM
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
11
12
13
13
14
15
15
16
17
18
19
19
20
22
23
24
26
. . . . . . . . . . 29
iii
iv
Notices
Note to U.S. Government Users Restricted Rights -- use, duplication or disclosure
restricted by GSA ADP Schedule Contract with IBM Corp.
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in
other countries. Consult your local IBM representative for information on the
products and services currently available in your area. Any reference to an IBM
product, program, or service is not intended to state or imply that only that IBM
product, program, or service may be used. Any functionally equivalent product,
program, or service that does not infringe any IBM intellectual property right may
be used instead. However, it is the users responsibility to evaluate and verify the
operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter
described in this document. The furnishing of this document does not give you
any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive
Armonk, NY 10504-1785
U.S.A.
For license inquiries regarding double-byte (DBCS) information, contact the IBM
Intellectual Property Department in your country or send inquiries, in writing, to:
IBM World Trade Asia Corporation
Licensing
2-31 Roppongi 3-chome, Minato-ku
Tokyo 106, Japan
The following paragraph does not apply to the United Kingdom or any other
country where such provisions are inconsistent with local law: INTERNATIONAL
BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION AS IS
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. Some states do not allow disclaimer of express or implied warranties in
certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors.
Changes are periodically made to the information herein; these changes will be
incorporated in new editions of the publication. IBM may make improvements
and/or changes in the product(s) and/or the program(s) described in this
publication at any time without notice.
Any references in this information to non-IBM Web sites are provided for
convenience only and do not in any manner serve as an endorsement of those Web
sites. The materials at those Web sites are not part of the materials for this IBM
product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it
believes appropriate without incurring any obligation to you.
Licensees of this program who wish to have information about it for the purpose
of enabling: (i) the exchange of information between independently created
programs and other programs (including this one) and (ii) the mutual use of the
information which has been exchanged, should contact:
Lab Director
IBM Canada Ltd.
1150 Eglinton Avenue East
Toronto, Ontario M3C 1H7
Canada
Such information may be available, subject to appropriate terms and conditions,
including in some cases, payment of a fee.
The licensed program described in this document and all licensed material
available for it are provided by IBM under terms of the IBM Customer Agreement,
IBM International Program License Agreement or any equivalent agreement
between us.
Information concerning non-IBM products was obtained from the suppliers of
those products, their published announcements or other publicly available sources.
IBM has not tested those products and cannot confirm the accuracy of
performance, compatibility or any other claims related to non-IBM products.
Questions on the capabilities of non-IBM products should be addressed to the
suppliers of those products.
This information contains examples of data and reports used in daily business
operations. To illustrate them as completely as possible, the examples include the
names of individuals, companies, brands, and products. All of these names are
fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which
illustrates programming techniques on various operating platforms. You may copy,
modify, and distribute these sample programs in any form without payment to
IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating
platform for which the sample programs are written. These examples have not
been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or
imply reliability, serviceability, or function of these programs. You may copy,
modify, and distribute these sample programs in any form without payment to
IBM for the purposes of developing, using, marketing, or distributing application
programs conforming to IBMs application programming interfaces.
Each copy or any portion of these sample programs or any derivative work, must
include a copyright notice as follows:
(your company name) (year). Portions of this code are derived from IBM Corp.
Sample Programs. Copyright IBM Corp. 1998, 2000. All rights reserved.
vi
vii
Microsoft, Win32, Windows, Windows NT, and the Windows logo are trademarks
or registered trademarks of Microsoft Corporation in the United States, or other
countries, or both.
Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
UNIX is a registered trademark in the U.S. and other countries licensed exclusively
through X/Open Company Limited.
ActionMedia, LANDesk, MMX, Pentium and ProShare are trademarks or registered
trademarks of Intel Corporation in the United States, or other countries, or both.
C-bus is a registered trademark of Corollary, Inc.
PC Direct is a registered tradmark of Ziff Communicatoins Company and is used
by IBM Corporation under license
Other company, product, and service names, which may be denoted by a double
asterisk(**), may be trademarks or service marks of others.
Industry Standards
VisualAge C++ Professional for AIX, Version 5.0 supports the following standards:
v The C language is consistent with the International Standard C (ANSI/ISO-IEC
98991990 [1992]). This standard has officially replaced American National
standard for Information Systems-Programming Language C (X3.1591989) and
is technically equivalent to the ANSI C standard. VisualAge C++ supports the
changes adopted into the C Standard by ISO/IEC 9899:1990/Amendment 1:1994.
v The IBM Systems Application Architecture (SAA) C Level 2 language definition.
v The C++ language is consistent with the International Standard for Information
Systems-Programming Language C++ (ISO/IEC 14882:1998).
v The ISO/IEC 99451:1990/IEEE POSIX 1003.-1990 standard.
v The X/Open Common Applications Environment Specifications, System
Interfaces and Headers, Issue 4.
viii
ix
#pragma
Description
code_seg
#pragma comment on
page 6
data_seg
)&
)&
)&
#pragma
Description
Registers an exception
handler for a function.
hashome
implementation
#pragma import on
page 14
ishome
isolated_call
#pragma
Description
linkage
margins
mc_func
Specifies machine
instructions for a particular
function.
#pragma namemangling
(C++) on page 19
#pragma object_model
(C++) on page 19
option_override
Specifies alternate
optimization options for
specific functions.
pack
page
pagesize
#pragma reachable on
page 23
#pragma
Description
reg_killed_by
seg16
sequence
skip
stack16
stack_align
title
weak
You must include the #pragma alloca directive to have the compiler provide an
inline version of alloca.
Once specified, it applies to the rest of the file and cannot be turned off. If a source
file contains any functions that you want compiled without #pragma alloca, place
these functions in a different file.
#pragma chars
Description
The #pragma chars directive sets the sign type of char objects to be either signed or
unsigned.
In C, this pragma must appear before any source statements, in order for
this pragma to take effect.
In C++ incremental mode, this pragma may be defined anywhere in the
source file. In C++ batch mode, the pragma must appear before any souce
statements.
Syntax
Once specified, it applies to the entire file and cannot be turned off. If a source file
contains any functions that you want to be compiled without #pragma chars, place
these functions in a different file. If the pragma is specified more than once in the
source file, the first one will take precedence.
Note: the default character type behaves like an unsigned char.
#pragma comment
Description
The #pragma comment directive places a comment into the target or object file.
Syntax
where:
compiler
date
timestamp
copyright
user
lib
For example:
#pragma define(Array<char>)
is equivalent to:
template class Array<char>;
This pragma must be defined in global scope (i.e. it cannot be enclosed inside a
function/class body).
Syntax
#pragma disjoint
Description
The #pragma disjoint directive lists the identifiers that are not aliased to each other
within the scope of their use.
Syntax
The directive informs the compiler that none of the identifiers listed shares the
same physical storage, which provides more opportunity for optimizations. If any
identifiers actually share physical storage, the pragma may cause the program to
give incorrect results. This pragma directive can be enabled or disabled by
specifying the opt(pragmadisjoint) option in the configuration file.
An identifier in the directive must be visible at the point in the program where the
pragma appears. The identifiers in the disjoint name list cannot refer to any of the
following:
v a member of a structure, or union
v
v
v
v
Example
int a, b, *ptr_a, *ptr_b;
#pragma disjoint(*ptr_a, b) // *ptr_a never points to b
#pragma disjoint(*ptr_b, a) // *ptr_b never points to a
one_function()
{
b = 6;
*ptr_a = 7; // Assignment does not alter the value of b
another_function(b); // Argument b has the value 6
}
Because external pointer ptr_a does not share storage with and never points to the
external variable b, the assignment of 7 to the object that ptr_a points to will not
change the value of b. Likewise, external pointer ptr_b does not share storage with
and never points to the external variable a. The compiler can assume that the
argument of another_function has the value 6 and will not reload the variable from
memory.
#pragma entry
Under the AIX platform, this pragma is not available for C, but is
available for C++.
Description
The #pragma entry directive specifies the function to be used as the entry point for
the application being built.
Syntax
The function_name is the name of the function to be used as an entry point. This
function must be in the same compilation unit as the #pragma entry directive. The
following types of functions cannot be used with #pragma entry:
v functions with C++ linkage
v C++ member functions
v template member functions
v overloaded functions
Under the OS/2 platform, your function must have _System linkage.
#pragma enum
Description
The #pragma enum directive specifies the size of enum variables that follow. The
size at the left brace of a declaration is the one that affects that declaration,
regardless of whether further enum directives occur within the declaration. This
pragma pushes a value on a stack each time it is used, with a reset option
available to return to the previously pushed value.
Syntax
int
1
2
4
pop
reset
Example:
#pragma
#pragma
#pragma
#pragma
#pragma
#pragma
enum(1)
enum(2)
enum(4)
enum(pop)
/* will reset enum size to 2 */
enum(reset) /* will reset enum size to 1 */
enum(pop) /* will reset enum size to default
Popping on an empty stack generates a warning message and the enum value
remains unchanged.
The gen(enumsize) option can be used to set the enum size to default. The
#pragma enum directive overrides gen(enumsize).
#pragma export
Under AIX, this pragma is not available for C, but it is available for
C++
Description
The #pragma export directive declares that a shared library function or variable is to
be exported and specifies the name of the function outside the shared library.
Syntax
10
where:
identifier
export_name
ordinal
_declspec Keyword
_Export Keyword
Keywords in C and C++
One of the compiler options, file(genpch, ...) or file(usepch, ...), must be specified to
allow more than one precompiled header to be use for a single application.
11
If a file name is specified both on the command line and on #pragma hdrfile, the
name specified on the pragma takes precedence. If the name specified is a
directory, then the the compiler searches for or generates a file with the default
name in that directory.
In order to maximize the reuse of precompiled headers, the use #pragma hdrfile in
combination with #pragma hdrstop to manually limit the initial sequence of
#include directives.
Use precompiled header files to decrease compile time. Using precompiled headers
will not improve compile time performance in most applications without some
organization of the headers included by each source file.
Examples using #pragma hdrfile (C)
12
It
v
v
v
Use precompiled header files to decrease compile time. Using precompiled headers
will not improve compile time performance in most applications without some
organization of the headers included by each source file.
Examples using #pragma hdrstop (C)
13
#pragma import
Under AIX, this pragma is not available for C, but it is available
for C++.
Description
The #pragma import directive lets you import a function or a variable from a shared
library using either an ordinal number or a name different from the one that it has
in the shared library.
Syntax
14
If an identifier is specified in more than one #pragma import, all instances of the
pragma must have the same export_name, module, and ordinal value. If the export
name, module name, or ordinal value are different, an error will occur.
For example, the following imports Joe from the TeamList:
#pragma import(player, Joe, TeamList, 2)
#pragma info
Description
The #pragma info directive controls the diagnostic messages generated by the
info(...) compiler option. The #pragma directive overrides any info(...) option stated
in the configuration file.
Syntax:
The effects of the options used with #pragma info are listed as follows:
all
none
restore
group
nogroup
For example:
#pragma info(ret)
15
change the value of the external variable a. The compiler can assume that the
argument to other_function has the value 6 and will not reload the variable from
memory.
int a;
// Assumed to have no side effects
int this_function(int);
#pragma isolated_call=this_function
that_function()
{
a = 6;
// Call does not change the value of a
this_function(7);
// Argument a has the value 6
other_function(a);
}
The isolated call compiler option has the same effect as this pragma. The ignprag
compiler option causes aliasing pragmas to be ignored. Use the ignprag compiler
option to debug applications containing the #pragma isolated_call directive.
#pragma isolated_call
This pragma can be specified only once in a source file, and it must appear before
any statements in a source file. The compiler uses predefined macros in the header
files to make declarations and definitions available that define the specified
language level.
ansi
extended
classic
16
saa
saal2
#pragma leaves
Description
The #pragma leaves directive takes a function name and specifies that the function
never returns to the instruction after the call.
Syntax
This pragma tells the compiler that the flow of the programs execution ends,
although the program does not terminate, when function is called.
The advantage of the pragma is that it allows the compiler to ignore any code that
exists after function, in turn, the optimizer can generate more efficient code. This
pragma is commonly used for custom error-handling functions, in which programs
can be terminated if a certain error is encountered. Some functions which also
behave similarily are exit, longjmp, and terminate.
Example
#pragma leaves(handle_error_and_quit)
void test_value(int value)
{
if (value == ERROR_VALUE)
{
handle_error_and_quit(value);
17
#pragma map
Description
The #pragma map directive tells the compiler that all references to an identifier are
to be converted to name.
Syntax
The follow list describes the options available for #pragma map:
identifier
function_signature
name
18
ansi
compat
Object Models
Preprocessor Directives - An Overview
Chapter 1. Preprocessor Directives - #pragma on page 1
objectModel Code Generation Option (C++)
19
Description
align=option
[no]ansialias
arch=option
assert=option
chars=option
[no]check
[no]compact
enum=option
flag=option
20
[no]flttrap=option
float=[no]option
[no]fold
[no]ignerrno
[no]info=option
initauto=value
[no]inlglue
isolated_call=names
[no]libansi
[no]longlong
[no]maxmem=number
priority=number
[no]ro
[no]roconst
[no]rwvftable
gen(vftReadOnly) .
spill=number
equivalent to option
opt(registerSpillSize,number).
[no]strict
tbtable=option
equivalent to option
link(traceBackTable,option).
tune=option
[no]unroll
unroll=number
[no]vftable
Description
Produces an attribute listing containing all names.
attr=full
[no]cinc=prefix
[no]dbcs
[no]dbxextra
[no]digraph
[no]dollar
[no]extchk
[no]funcsect
[no]fullpath
genpcomp
halt
[no]idirfirst
langlvl
[no]ldbl128
list
[no]longdouble
[no]mbcs
macpstr
once
21
showinc
som (C++)
somgs (C++)
source
srcmsg
nostdinc
[no]upconv
xref
By default, the options specified apply to the entire source program. If you specify
more than one compiler option, use a blank space to separate them.
If certain options are to apply to the entire program, then the #pragma
options directive should be specified before any statements.
Eight compiler options that can be specified with the #pragma options directive
have corresponding preprocessor #pragma directives. They are:
#pragma option Name
#pragma Name
chars
enum
flag
info
isolated_call
isolated_call
langlvl
priority
ro
Build Options
Optimization Options
Code Generation Options
22
The #pragma priority directive specifies the order in which static objects are to be
initialized at run time.
Syntax
#pragma reachable
Description
The #pragma reachable directive declares that the point after the call to a routine,
function, can be the target of a branch from some unknown location. This pragma
should be used in conjunction with setjmp.
Syntax
23
where:
level
24
E|W|I
enable | disable
message_number
pop
I: signifies a minimum
message severity of
information. Information
messages are considered as
the least severe type of
diagnostic message. A level
of I would display messages
of all types. The VisualAge
C++ development
environment sets this as the
default option. An alternative
way of setting the report
level to I is by specifying
the report(level, I) compiler
option.
enables or disables the
specified message number.
is an identifier containing the
message number prefix,
followed by the message
number. An example of a
message number is:
CPPC1004
resets the report level back to
the previous report level. If a
pop operation is performed
on an empty stack, the report
level will remain unchanged
and no message will be
generated.
25
Examples
1
2
#pragma info(all)
#pragma report(level, W)
#pragma report(level, E)
#pragma report(enable, CPPC1000)
would yield the same result. The order in which the two lines of code appear in,
does not affect the outcome. However, if the message was disabled, then
regardless of what report level is set and order the lines of code appear in, the
diagnostic message will not be displayed.
1
2
3
4
#pragma
#pragma
#pragma
#pragma
report(level, I)
report(enable, CPPC1000)
report(level, E)
report(pop)
In line 1 of the example above, the initial report level is set to I, causing message
CPPC1000 to display regardless of the type of diagnostic message it classified as.
In line 3, a new report level of E is set, indicating at only messages with a
severity level of E will be displayed. Immediately following line 3, the current
level E is popped and reset back to I.
#pragma info
report level Miscellaneous Option - report(level, ...)
#pragma strings
Description
The #pragma strings directive sets storage type for strings. It specifies that the
compiler can place strings into read-only memory or must place strings into
read/write memory. Unlike previous versions of VisualAge C++, this pragma can
appear anywhere in a source file.
For code that will be compiled with the C compiler, this pragma must
appear before any C code.
Syntax
26
27
28
Contacting IBM
Were delighted to offer a solid cornerstone for your application development:
IBMs comprehensive support services. Whether you are an occasional user with a
simple question, a power user with many complex technical questions, or someone
who requires application design assistance and consulting, IBM Support can meet
your needs.
Comments on This Help
Please let us know about any errors or omissions in this online help or in the
hardcopy Getting Started book, or our PDF documents. Send your e-mail to:
torrcf@ca.ibm.com
Fee Support
Developers on the VisualAge C++ for AIX Service and Support team handle
everything from simple how-tos to complex technical problems. Solutions may
take the form of a brief explanation, a workaround, a fix to the current product, or
a fix to the next release.
http://www.ibm.com/support/ describes IBM Support Offerings on all platforms,
worldwide.
http://www.ibm.com/rs6000/support/ describes support offerings on the
RS/6000 platform, in your country. It also indicates whether your country
provides support electronically over the Internet in addition to telephone support.
http://www.lotus.com/passport describes the IBM and Lotus Passport
Advantage contracting option.
The IBM Software Support Handbook, accessible from
http://www.ibm.com/software/support, also lists worldwide support contacts.
Phone numbers for information on Support Line offerings are:
v United States: 1-888-426-4343 (IBM Global Services), option 3 as of December
1999. Should this number change, IBM general information at 1-800-IBM-4YOU
(1-800-426-4968) can route you to the appropriate group.
v Canada: 1-800-465-9600, option 3 as of December 1999. Should this number
change, you can also contact IBM general information at 1-800-IBM-4YOU
(1-800-426-4968).
Please call 1-800-266-8720 in the U.S. and Canada for information on Passport
Advantage offerings.
v Elsewhere, please contact your local IBM office.
If you contact support, please have the following information available:
v The product name
v The product version
v The hardware configuration and software (product names and versions you are
using)
v What happened and what you were doing when the problem occurred
Copyright IBM Corp. 1998, 2000
29
30