#pragma namemanglingrule (C++ only)

Category

Portability and migration

Purpose

Provides fined-grained control over the name mangling scheme in effect for selected portions of source code, specifically with respect to the mangling of cv-qualifiers in function parameters.

When a function name is mangled, repeated function arguments of the same type are encoded according to the following compression scheme:
parameter → T param number [_]   #single repeat of a previous parameter
         → N repetition digit param number [_]    #2 to 9 repetitions
where:
param number
Indicates the number of the previous parameter which is repeated. It is followed by an underscore (_) 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.
The #pragma namemanglingrule directive allows you to control whether top-level cv-qualifiers are mangled in function parameters or whether intermediate-level cv-qualifiers are to be considered when the compiler compares repeated function parameters for equivalence.

Syntax

Read syntax diagramSkip visual syntax diagram
                                                    .-on--.                
>>-#--pragma--namemanglingrule--(--+-fnparmtype--,--+-off-+---------+--)-><
                                   |                '-pop-'         |      
                                   |                .-on--.         |      
                                   +-fnparmscmp--,--+-off-+---------+      
                                   |                '-pop-'         |      
                                   |                        .-on--. |      
                                   '-fnparmstypedefscmp--,--+-off-+-'      
                                                            '-pop-'        

Defaults

Parameters

fnparmtype, on
Top-level cv-qualifiers are not encoded in the mangled name of a function parameter. Also, top-level cv-qualifiers are ignored when repeated function parameters are compared for equivalence; function parameters that differ only by the use of a top-level cv-qualifier are considered equivalent and are mangled according to the compressed encoding scheme. This setting is compatible with VisualAge® C++ V6.0 and higher.
fnparmtype, off
Top-level cv-qualifiers are encoded in the mangled name of a function parameter. Also, repeated function parameters that differ by the use of cv-qualifiers are not considered equivalent and are mangled as separate parameters. This setting is compatible with VisualAge C++ V5.0 and earlier.
fnparmtype, pop
Reverts to the previous fnparmtype setting in effect. If no previous settings are in effect, the default fnparmtype setting is used.

Note: This pragma fixes function signature ambiguities in 32-bit mode, but it is not needed in 64-bit mode since those ambiguities do not exist in 64-bit mode.

fnparmscmp, on
Intermediate-level cv-qualifiers are considered when repeated function parameters are compared for equivalence; repeated function parameters that differ by the use of intermediate-level cv-qualifiers are mangled as separate parameters. This setting is compatible with XL C++ V8.0 and higher.
fnparmscmp, off
Intermediate-level cv-qualifiers are ignored when repeated function parameters are compared for equivalence; function parameters that differ only by the use of an intermediate-level cv-qualifier are considered equivalent and are mangled according to the compressed encoding scheme. This setting is compatible with XL C++ V7.0 and earlier.
fnparmscmp, pop
Reverts to the previous fnparmscmp setting in effect. If no previous settings are in effect, the default fnparmscmp setting is used.

Usage

#pragma namemanglingrule is allowed in global, class, and function scopes. It has no effect on a block scope function declaration with external linkage.

Different pragma settings can be specified in front of function declarations and definitions. If #pragma namemanglingrule settings in subsequent declarations and definitions conflict, the compiler ignores those settings and issues a warning message.

Examples

The following tables show the effects of this pragma applied to different function signatures.

Table 1. Mangling of function parameters with top-level cv-qualifiers
Source name Mangled name

fnparmtype, off

fnparmtype, on
void foo (const int) foo__FCi foo__Fi
void foo (int* const) foo__FCPi foo__FPi
void foo (int** const) foo__FCPPi foo__FPPi
void foo (int, const int) foo__FiCi foo__FiT1
Table 2. Mangling of function parameters with intermediate level cv-qualifiers
Source name Mangled name

fnparmscmp, on

fnparmscmp, off
void foo (int** a, int* const * b) foo__FPPiPCPi foo__FPPiT1
void bar (int* const* a, int** b) bar__FPCPiPPi bar__FPCPiT1
Table 3. Mangling of function parameters with top-level and intermediate-level cv-qualifiers
Source name Mangled name    

fnparmscmp, on
fnparmtype, on

fnparmscmp, off
fnparmtype, on

fnparmscmp, on
fnparmtype, off

fnparmscmp, off
fnparmtype, off

void foo (int** const, int* const *) foo__FPPiPCPi foo__FPPiT1 foo__FCPPiPCPi foo__FPPiT1

Related information