Pragma equivalent
#pragma namemangling
Purpose
Chooses the name mangling scheme for
external symbol names generated from C++ source code.
The
option and pragma are provided to ensure binary compatibility with
link modules created with previous versions of the compiler. If you
do not need to ensure backwards compatibility, it is recommended that
you do not change the default setting of this option.
Syntax
Option syntax
.-ansi---.
>>- -q--namemangling--=--+-v11----+----------------------------><
+-v10----+
+-v9-----+
+-v8-----+
+-v7-----+
+-v6-----+
+-v5-----+
+-v4-----+
+-v3-----+
'-compat-'
Pragma syntax
.-ansi---.
>>-#--pragma--namemangling--(--+-+-v11----+--+--------------+-+--)-><
| +-v10----+ '-,--num_chars-' |
| +-v9-----+ |
| +-v8-----+ |
| +-v7-----+ |
| +-v6-----+ |
| +-v5-----+ |
| +-v4-----+ |
| +-v3-----+ |
| '-compat-' |
'-pop--------------------------'
Defaults
-qnamemangling(ansi, 64000)
Parameters
- ansi
- The name mangling scheme supports the most recent Standard
C++ language features. This suboption is equivalent to v11.
- v3 | compat
- The name mangling scheme is compatible with VisualAge® C++ V3.0 in 32-bit mode only.
- v4
- The name mangling scheme is compatible with VisualAge C++ V4.0. Prior to this release,
a function and a function template specialization with the same name
and parameter list were considered to have the same signature, and
the following test case would fail to compile:
int f(int) {
return 42;
}
template < class T > int f(T) {
return 43;
}
int main() {
f < int > (3); // instantiate int f < int > (int)
return f(4);
}
From V4.0 on, the compiler treats a function and a function
template specialization with the same name and parameter list as distinct
functions. The following examples illustrate this behavior: Source name |
Mangled name prior to v4 |
Mangled name in v4 and higher |
int f (int) |
f__Fi |
f__Fi |
int f <int> (int) |
f__Fi |
f__Hi_i_i |
- v5
- The name mangling scheme is compatible with VisualAge C++ V5.0. Same as the v4 suboption.
- v6
- The name mangling scheme is compatible with VisualAge C++ V6.0. Prior
to this release, top-level cv-qualifiers in function arguments were
encoded in mangled names. From V6.0 on, in accordance with the C++
Standard, top-level cv-qualifiers are not considered part of the underlying
type of a function argument, and the cv-qualifiers are not encoded
in the mangled names. The following examples illustrate this behavior:
Source name |
Mangled name prior to v6 |
Mangled name in v6 and higher |
void foo (const int) |
foo__FCi |
foo__Fi |
void foo (int* const) |
foo__FCPi |
foo__FPi |
- v7
- The name mangling scheme is compatible with IBM® XL C/C++ V7.0.
Several changes to the
mangling scheme went into effect in IBM XL
C/C++ V7.0. First of all, prior to V7.0, top-level cv-qualifiers were
used to distinguish between types in repeated parameters in a function's
signature. From V7.0 on, in accordance with the C++ Standard, top-level
cv-qualifiers are ignored for determining the equivalence between
function parameters. Parameters that are only differentiated by the
presence of a top-level cv-qualifier are considered to be equivalent,
and are represented in the compressed encoding scheme used for repeated
parameters of the same type. The following examples illustrate this
behavior:
Source name |
Mangled name prior to v7 |
Mangled name in v7 and higher |
void foo (int, const int) |
foo__FiCi (pre-v6)
foo__Fii (v6)
|
foo__FiT1 |
void foo (int* const, int* const) |
foo__FCPiCCPi (pre-v6)
foo__FPiPi (v6)
|
foo__FPiT1 |
Note: This behavior can also be controlled with the use
of the
nameManglingRule(fnparmtype) pragma directive.
For more information, as well as details of the compressed mangling
scheme, see
#pragma namemanglingrule (C++ only).
Secondly,
prior to V7.0, non-type integral template arguments were mangled as
32-bit unsigned decimal numbers prefixed by SP.
Due to ambiguities introduced by this in mangling 64-bit values, this
scheme has been changed to the following:
non-type template argument → SM #single repeat of a previous parameter
→ SP number #positive internal argument
→ SN number #negative internal argument
When
a non-type integral template argument is positive, the number is prefixed
with
SP. When a non-type integral template argument
is negative, the number is prefixed with SN, and the decimal number
is written without the minus sign. There is no limit in the range
of decimal numbers which can be represented. The following examples
illustrate this behavior:
Source name |
Mangled template name prior to v7 |
Mangled template name in v7 and higher |
template <int n> int foo()
{ return N; }
int main()
{ return foo<-3>(); }
|
foo__HxiSP429 |
foo__HxiSN3x_v |
- v8
- The name mangling scheme is compatible with IBM XL C/C++ V8.0.
Several changes to the
mangling scheme went into effect in IBM XL
C/C++ V8.0. First of all, prior to V8.0, intermediate-level cv-qualifiers
were not used to distinguish between types in repeated parameters
in a function's signature. From V8.0 on, intermediate-level cv-qualifiers
are used for determining the equivalence between function parameters.
Parameters that are differentiated by the presence of an intermediate-level
cv-qualifier are not considered to be equivalent, and are mangled
as separate parameters. The following examples illustrate this behavior:
Source name |
Mangled name prior to v8 |
Mangled name in v8 and higher |
void foo (int**, int* const *) |
foo__FPPiT1 |
foo__FPPiPCPi |
Note: This behavior can also be controlled with the use of
the
nameManglingRule(fnparmscmp) pragma directive.
For more information, as well as details of the compressed mangling
scheme, see
#pragma namemanglingrule (C++ only).
Secondly,
prior to V8.0, only the underlying type in a
typedef definition
was used to distinguish between types in repeated parameters in a
function's signature. From V8.0 on, the name defined in a typedef
declaration in a template parameter is encoded as a separate parameter
in the mangled name of a template function that uses the typedef as
a parameter. The following examples illustrate this behavior:
Source name |
Mangled function name prior to v8 |
Mangled function name in v8 and higher |
template <typename T>
struct A {
typedef int foo;
};
template <typename V>
int bar (A <V>, int, typename A<V>::foo) {}
A<int> a;
int x = bar (a, 1, 10);
|
bar__Hi_1AXTi_iT2_i |
bar__Hi_1AXTi_iQ2_1AXTi_9foo_i |
template <typename T>
struct A {
typedef A foo;
};
template <typename Y>
int bar (A <int>::foo, const A<Y>) {}
A<int> a;
int x = bar (10, a);
|
bar__Hi_1AXTi_T1_i |
bar__Hi_Q2_1AXTi_foo1AXTi__i |
- v9
- The name mangling scheme is compatible with IBM XL C/C++ V9.0.
Prior to this release, the
name mangling scheme did not different between different pointer-to-member
template arguments in template instantiations, and the following test
case would fail to compile:
struct pair { int x, y;
pair(int x_, int y_) : x(x_), y(y_) {} };
template <int pair::*PtrToPairMember>
struct foo { int bar(pair& p) { return p.*PtrToPairMember; }
};
template <int pair::*PtrToPairMember> func(pair& p) { return p.*PtrToPairMember; }
int main() {
pair p(0, 1);
foo<&pair::x> fx;
foo<&pair::y> fy;
if (fx.bar(p) != 0 || fy.bar(p) != 1) { return 1; }
if (func<&pair::x>(p) != 0 || func<&pair::y>(p) != 1) { return 2; }
return 0;
}
From V9.0 on, the compiler treats different pointer-to-member
template arguments as distinct. The following examples illustrate
this behavior:
Source name |
Mangled name prior to v9 |
Mangled name in v9and higher |
int foo<&pair::y>::bar(pair &) |
bar_3fooXA0_FR4pair |
bar_3fooXAM1y_FR4pair |
int foo<&pair::x>::bar(pair &) |
bar_3fooXA0_FR4pair |
bar_3fooXAM1x_FR4pair |
int func<&pair::y>(pair &) |
func_HxM4pairiA0x_R4pair_i |
func_HxM4pairiA0yx_R4pair_i |
int func<&pair::x>(pair &) |
func_HxM4pairiA0x_R4pair_i |
func_HxM4pairiA0xx_R4pair_i |
- v10
- The name mangling scheme is compatible with IBM XL C/C++ V10.1. This suboption
has the same effect as the v9 suboption.
- v11
- The name mangling scheme is compatible with IBM XL C++ V11.1. This suboption is equivalent
to ansi and has the same effect as v10.
- num_chars (pragma only)
- Specifies the maximum number of allowable characters in the mangled
names. If you do not specify this suboption, the default maximum is
64000 characters for all settings except v3 and compat,
for which the default maximum is 255 characters.
- pop
- Discards the current pragma setting and reverts
to the setting specified by the previous pragma directive. If no previous
pragma was specified, reverts to the command-line or default option
setting.