-qnamemangling (C++ only)
Category
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 compatibility with earlier versions, do not change the default setting of this option.
Syntax
Option syntax .-v13----. >>- -q--namemangling--=--+-v12----+---------------------------->< +-v11----+ +-v10----+ +-v9-----+ +-v8-----+ +-v7-----+ +-v6-----+ +-v5-----+ +-v4-----+ +-v3-----+ +-ansi---+ '-compat-'
Pragma syntax .-v13----. >>-#--pragma--namemangling--(--+-+-v12----+-+--)--------------->< | +-v11----+ | | +-v10----+ | | +-v9-----+ | | +-v8-----+ | | +-v7-----+ | | +-v6-----+ | | +-v5-----+ | | +-v4-----+ | | +-v3-----+ | | +-ansi---+ | | '-compat-' | '-pop--------'
Defaults
-qnamemangling(v13)
Parameters
- ansi
- The name mangling scheme supports the most recent standard C++ language features. This suboption is equivalent to v13.
- v13
- The name mangling scheme is compatible with IBM® XL C/C++ V13.1. Several changes to the name mangling scheme are introduced in IBM XL C/C++ V13.1. Firstly, before V13.1, suppose there are two functions whose only difference is that one has cv-qualified parameters while the other's parameters are not cv-qualified. When you use the typeid operator to retrieve the types of these two functions, the mangled names for the function types were inconsistent. See the following example.
#include <typeinfo> #include <stdio.h> int main( ){ if( typeid(void (*)(int)) == typeid(void (*)(const int)) ) printf("success\n"); else printf("failure\n"); return 0; }
Before V13.1, the mangled names of the two functions typeid(void (*)(int)) and typeid(void (*)(const int)) were not identical; in V13.1, the mangled names are identical as shown in the following table.Function type Mangled name before v13 Mangled name in v13 typeid(void (*)(int)) __type_infoXTPFi_v_ __type_infoXTPFi_v_ typeid(void (*)(const int)) __type_infoXTPFCi_v_ __type_infoXTPFi_v_ Secondly, before V13.1, mangled names for unnamed namespaces distinguish themselves from other functions or namespaces only by their file names. When multiple unnamed namespaces are in separate files that have the same file name but different directories, the mangled names of these namespaces are the same. The V13.1 release fixes this problem by encoding the file directory with file name in the mangled function name. For example, the following code is included in two files with the same file name test.cpp under directory dir1 and directory dir2:namespace{ struct C{ C(){ printf("%s\n", "C() of c1"); } }c1; }
Before V13.1, the two constructors C() under directory dir1 and directory dir2 had identical mangled names. When static initialization occurs and the object files are linked or loaded to a main program, only the first constructor that is identified by the linker is called or initialized. In V13.1, the mangled names for the two constructors are different as shown in the following table.Function Mangled name before v13 Mangled name in v13 test.cpp under directory dir1: C() __ct__Q2_10test.cpp-01CFv __ct__Q2_101_test_cpp1CFv test.cpp under directory dir2: C() __ct__Q2_10test.cpp-01CFv __ct__Q2_102_test_cpp1CFv - v12
- The name mangling scheme is compatible with IBM XL C/C++ V12.1.Before this release, the name mangling scheme did not distinguish function parameters of template types that were cv-qualified and not cv-qualified, because the cv-qualifiers of the template type parameters were ignored. The v12 fix preserves the cv-qualifiers, so the function parameters that are cv-qualified and not cv-qualified are handled differently. For example:
In the preceding example, before the v12 fix, Iterator<const int> operator+(Iterator<const int>, long)() and Iterator<int> operator+(Iterator<int>, long)() had an identical name mangling __pl__F8IteratorXTi_l. The fix distinguishes the name mangling of these two functions as shown in the following table:template<typename Element> struct Iterator { Iterator() {} Iterator<Element>& operator+=(long d); friend Iterator<Element> operator+(Iterator<Element> it, long d) { it += d; return it; } }; int main() { Iterator<int> iter; Iterator<const int> c_iter; iter = iter+10; c_iter=c_iter+10; }
Source name Mangled name before v12 Mangled name in v12 and later Iterator<const int> operator+(Iterator<const int>, long) __pl__F8IteratorXTi_l __pl__F8IteratorXTCi_l Iterator<int> operator+(Iterator<int>, long)() __pl__F8IteratorXTi_l __pl__F8IteratorXTi_l - v11
- The name mangling scheme is compatible with IBM XL C/C++ V11.1. This suboption has the same effect as v10.
- v10
- The name mangling scheme is compatible with IBM XL C/C++ V10.1. This suboption has the same effect as the v9 suboption.
- v9
- The name mangling scheme is compatible with IBM XL C/C++ V9.0.Before 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:
From V9.0 on, the compiler treats different pointer-to-member template arguments as distinct. The following examples illustrate this behavior:struct pair { int x, y; pair(int x_, int y_) : x(x_), y(y_) {} }; template <int pair::*PtrToPairMember> struct str { int f(pair& p) { return p.*PtrToPairMember; } }; template <int pair::*PtrToPairMember> g(pair& p) { return p.*PtrToPairMember; } int main() { pair p(0, 1); str<&pair::x> fx; str<&pair::y> fy; if (fx.f(p) != 0 || fy.f(p) != 1) { return 1; } if (g<&pair::x>(p) != 0 || g<&pair::y>(p) != 1) { return 2; } return 0; }
Source name Mangled name before v9 Mangled name in v9 and later int str<&pair::y>::f(pair &) f_3strXA0_FR4pair f_3strXAM1y_FR4pair int str<&pair::x>::f(pair &) f_3strXA0_FR4pair f_3strXAM1x_FR4pair int g<&pair::y>(pair &) g_HxM4pairiA0x_R4pair_i g_HxM4pairiA0yx_R4pair_i int g<&pair::x>(pair &) g_HxM4pairiA0x_R4pair_i g_HxM4pairiA0xx_R4pair_i - 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, before 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 before v8 Mangled name in v8 and later void f (int**, int* const *) f__FPPiT1 f__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, before 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 before v8 Mangled function name in v8 and later template <typename T> struct A { typedef int INT; }; template <typename V> int f (A <V>, int, typename A<V>::INT) {} A<int> a; int x = f (a, 1, 10);
f__Hi_1AXTi_iT2_i f__Hi_1AXTi_iQ2_1AXTi_9INT_i template <typename T> struct A { typedef A INT; }; template <typename Y> int f (A <int>::INT, const A<Y>) {} A<int> a; int x = f (10, a);
f__Hi_1AXTi_T1_i f__Hi_Q2_1AXTi_INT1AXTi__i - 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, before 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 before v7 Mangled name in v7 and later void f (int, const int) f__FiCi (pre-v6)
f__Fii (v6)f__FiT1 void f (int* const, int* const) f__FCPiCCPi (pre-v6)
f__FPiPi (v6)f__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, before 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 before v7 Mangled template name in v7 and later template <int n> int f(){ return N; } int main(){ return f<-3>(); }
f__HxiSP429 f__HxiSN3x_v - v6
- The name mangling scheme is compatible with VisualAge® C++ V6.0. Before 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 before v6 Mangled name in v6 and later void f (const int) f__FCi f__Fi void f (int* const) f__FCPi f__FPi Note: This behavior can also be controlled with the use of the nameManglingRule(fnparmtype) pragma directive. For more information, see #pragma namemanglingrule (C++ only). - v5
- The name mangling scheme is compatible with VisualAge C++ V5.0. Same as the v4 suboption.
- v4
- The name mangling scheme is compatible with VisualAge C++ V4.0. Before 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:
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: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); }
Source name Mangled name before v4 Mangled name in v4 and later int f (int) f__Fi f__Fi int f <int> (int) f__Fi f__Hi_i_i - v3 | compat
- The name mangling scheme is compatible with VisualAge C++ V3.0 in 32-bit mode only.
- 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.
Predefined macros
None.