NAMEMANGLING (C++ only)

Category

Portability and migration

Pragma equivalent

#pragma namemangling (C++ only)

Purpose

Specifies the name mangling scheme for external symbol names which have C++ linkage.

Syntax

Read syntax diagramSkip visual syntax diagram
                   .-zOSV1R2---------.     
>>-NAMEMANGLING--(-+-ANSI------------+-)-----------------------><
                   +-zOSV2R1_ANSI----+     
                   +-zOSV1R12_ANSI---+     
                   +-zOSV1R11_ANSI---+     
                   +-zOSV1R10_ANSI---+     
                   +-zOSV1R9_ANSI----+     
                   +-zOSV1R8_ANSI----+     
                   +-zOSV1R7_ANSI----+     
                   +-zOSV1R5_ANSI----+     
                   +-zOSV1R5_DEFAULT-+     
                   +-OSV2R10---------+     
                   '-COMPAT----------'     

Defaults

By default, the NAMEMANGLING option is set as follows:
  • ZOSV1R2 — If LANGLVL is set to ANSI, EXTENDED or EXTENDED0X.
  • COMPAT — If LANGLVL is set to COMPAT92.
  • ANSI — If LP64 is set; the effect of LP64 takes precedence over the effect of LANGLVL.

Parameters

The NAMEMANGLING compiler option enables you to choose between the following name mangling schemes:

ANSI
This scheme complies with the most recent C++ language features and is equivalent to zOSV2R1_ANSI.
zOSV2R1_ANSI
This scheme is compatible with z/OS® XL C++ V2R1 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R12_ANSI
This scheme is compatible with z/OS XL C++ V1R12 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R11_ANSI
This scheme is compatible with z/OS XL C++ V1R11 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R10_ANSI
This scheme is compatible with z/OS XL C++ V1R10 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R9_ANSI
This scheme is compatible with z/OS XL C++ V1R9 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R8_ANSI
This scheme is compatible with z/OS XL C++ V1R8 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R7_ANSI
This scheme is compatible with z/OS XL C++ V1R7 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R5_ANSI
This scheme is compatible with z/OS XL C++ V1R5 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
zOSV1R5_DEFAULT
This scheme ensures backwards compatibility with previous z/OS XL C++ versions and is equivalent to ZOSV1R2.
zOSV1R2
This scheme is compatible with z/OS XL C++ V1R2 link modules that were created with NAMEMANGLING(ANSI) or #pragma namemangling(ansi).
OSV2R10
This scheme is compatible with the link modules created by OS/390® C++ V2R10 or previous versions, or with link modules that were created with NAMEMANGLING(COMPAT) or #pragma namemangling(compat).
COMPAT
This scheme is equivalent to OSV2R10.

Usage

Name mangling is the encoding of variable names into unique names so that linkers can separate common names in the language. With respect to the C++ language, name mangling is commonly used to facilitate the overloading feature and visibility within different scopes.

Note: If the NAMEMANGLING compiler option is not specified, LANGLVL(EXTENDED) and LANGLVL(ANSI) set NAMEMANGLING to zOSV1R2. LANGLVL(COMPAT92) sets NAMEMANGLING to COMPAT.

The NAMEMANGLING compiler option takes precedence over the LP64 compiler option. The LP64 compiler option takes precedence over the LANGLVL compiler option. When the NAMEMANGLING and LANGLVL compiler options are specified, the last specified option takes precedence. This is to preserve the V1R2 behavior so that existing code is not broken.

Predefined macros

None.

Examples

The following table shows some examples of the NAMEMANGLING options that are in effect when certain compiler options are specified:

Table 1. Examples of NAMEMANGLING in effect
Compiler option(s) specified NAMEMANGLING in effect
NAMEMANGLING(zOSV1R2) zOSV1R2
LANGLVL(COMPAT92) COMPAT
LP64 ANSI
NAMEMANGLING(zOSV1R2) LANGLVL(COMPAT92) COMPAT
LANGLVL(COMPAT92) NAMEMANGLING(zOSV1R2) zOSV1R2
NAMEMANGLING(zOSV1R2) LP64 zOSV1R2
LP64 NAMEMANGLING(zOSV1R2) zOSV1R2
LANGLVL(COMPAT92) LP64 ANSI
LP64 LANGLVL(COMPAT92) ANSI
NAMEMANGLING(zOSV1R2) LANGLVL(COMPAT92) LP64 COMPAT
NAMEMANGLING(zOSV1R2) LP64 LANGLVL(COMPAT92) COMPAT
LP64 NAMEMANGLING(zOSV1R2) LANGLVL(COMPAT92) COMPAT
LP64 LANGLVL(COMPAT92) NAMEMANGLING(zOSV1R2) zOSV1R2
LANGLVL(COMPAT92) LP64 NAMEMANGLING(zOSV1R2) zOSV1R2
LANGLVL(COMPAT92) NAMEMANGLING(zOSV1R2) LP64 zOSV1R2

Related information