OBJECTMODEL (C++ only)
Category
Object code control
Pragma equivalent
#pragma object_model (C++ only)
Purpose
Sets the object model to be used for structures, unions, and classes.
Syntax
Defaults
OBJECTMODEL(CLASSIC)
Parameters
- CLASSIC
- CLASSIC refers to the original object model that was available
on all previous releases of C++ compiler.Note: Suboption OBJECTMODEL(COMPAT) is changed to OBJECTMODEL(CLASSIC), but COMPAT is still accepted as the synonym of CLASSIC.
- IBM
- 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. Notes:
- When you compile with the OBJECTMODEL(IBM) option,
and the
dynamic_cast
operator is used in a constructor, a destructor, or in functions called from a constructor or destructor, thedynamic_cast
operator has the following behavior:- Does not return a pointer or a reference to the derived object from the class for the constructor or destructor.
- Returns NULL.
- When you compile with the LP64 compiler option, the OBJECTMODEL(IBM) compiler option is specified along with XPLINK.
- In order to use the OBJECTMODEL(IBM) option, the XPLINK option must be specified. If XPLINK is not specified, the compiler will issue a warning and use the default OBJECTMODEL(CLASSIC) setting.
- When you compile with the OBJECTMODEL(IBM) option,
and the
Usage
z/OS® XL C++ includes two ways to compile your
programs using different object models. The two object models, CLASSIC
and IBM,
differ in the following areas:
- Layout for the virtual function table
- Name mangling scheme
IPA effects
The IPA link step does not accept the OBJECTMODEL option. The compiler issues a warning message if you specify this option in the IPA link step.
Predefined macros
- __OBJECT_MODEL_CLASSIC__ is predefined to a value of 1 when the OBJECTMODEL(CLASSIC) compiler option is in effect; otherwise it is undefined.
- __OBJECT_MODEL_IBM__ is predefined to a value of 1 when the OBJECTMODEL(IBM) compiler option is in effect; otherwise it is undefined.
Note: The legacy macro __OBJECT_MODEL_COMPAT__ is predefined
to a value of 1 when the OBJECTMODEL(CLASSIC) compiler option is in
effect. It is recommended to use macro __OBJECT_MODEL_CLASSIC__ instead.
Related information
- For more information about the XPLINK compiler option, see XPLINK | NOXPLINK.