-qnamemangling

C++ only

Description

Chooses the name mangling scheme for external symbol names generated from C++ source code.

Syntax

Read syntax diagramSkip visual syntax diagram                         .-ansi---.
>>- -q--namemangling--=--+-v6-----+----------------------------><
                         +-v5-----+
                         +-v4-----+
                         +-v3-----+
                         '-compat-'

where available choices for mangling schemes are:

ansi The name mangling scheme fully supports the various language features of Standard C++, including function template overloading.
v6 The name mangling scheme is compatible with VisualAge C++ version 6.0.
v5 The name mangling scheme is compatible with VisualAge C++ version 5.0.
v4 The name mangling scheme is compatible with VisualAge C++ version 4.0.
v3 Use this scheme for compatibility with link modules created with versions of VisualAge C++ released prior to version 4.0, or with link modules that were created with the #pragma namemangling or -qnamemangling=compat compiler options specified.

This scheme cannot be used when a function has the same name and the same function parameter list as a function template specialization. For example, XL C++ issues a diagnostic message when the following test case is compiled and the option -qnamemangling=compat is enabled:

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); 
}
The error message returned will be:
(S) The definitions of "int f < int > (int)" and 
    "int f(int)" have the same linkage signature "f__Fi".
compat Same as the v3 suboption, described above.

See also #pragma namemangling.

Notes

Function parameter list mangling for repeated parameters of the same function parameter type has changed under the -qnamemangling=ansi option. Under the -qnamemangling=ansi scheme change, repeated function parameters now ignore top-level cv-qualifiers when they are compared to determine if they have the same type. Repeated parameters of the same function parameter type are mangled according to the compressed encoding scheme as follows:

<parameter> ::= T <param number> [_]   #single repeat of a previous parameter
            ::= N <repetition digit> <param number> [_]    #2 to 9 repetitions
where:
<param number> Indicates the previous parameter number, which is repeated. It is followed by an '_' if <param number> contains multiple digits.
<repetition digit> Must be greater than 1 and less than 10. If an argument is repeated more than 9 times, this rule is applied multiple times. For example, a sequence of 38 parameters that are the same as parameter 1 mangles to "N91N91N91N91N21".

Previously, the mangling of non-type integral template arguments was written as a 32-bit unsigned decimal number and prefixed by 'SP'. Due to ambiguities introduced by this in mangling 64-bit values, this scheme has been changed for -qnamemangling=ansi:

<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.

This breaks binary compatibility with templates using negative non-type integral arguments other than INT_MIN, as well as positive integral values, which cannot be represented in a 32-bit quantity. To preserve binary compatibility, you can instruct the compiler to use the namemangling scheme in place prior to this change by specifying -qnamemangling=v6 or #pragma namemangling(v6).

You can use the #pragma namemangling directive to protect your header files against changes in namemangling schemes. For example, to always ensure that a given header file uses the v5 namemangling scheme, insert #pragma namemangling(v5)at the top of your header file, and append #pragma namemangling(pop) at the bottom of the file.

Related information