Appendix I: Decorated Names
Appendix I  Decorated Names

This appendix discusses compiler-generated decorated names for functions in C and C++ programs. A decorated name is sometimes required when you specify a function name to LINK or other tools. For details about the situations that require decorated names, consult the documentation for the tool you are using.


I.1  Overview

Functions in C and C++ programs are known internally by their decorated names. A decorated name is a string created by the compiler during compilation of the function definition or prototype.


Format of a C++ Decorated Name

A decorated name for a C++ function contains the following information:

•	The function name.

•	The class that the function is a member of, if it is a member function. This may include the class that encloses the function's class, and so on.

•	The types of the function's parameters.

•	The calling convention.

•	The return type of the function.

The function and class names are expressed literally in the string. The rest of the string is a code that has internal meaning only for the compiler and linker. The following are examples of undecorated and decorated C++ names:

Undecorated Name	Decorated Name
int a(char){int i=3;return i;};	?a@@YAHD@Z
void __stdcall b::c(float){};	?c@b@@QAGXM@Z


Format of a C Decorated Name

The form of decoration for a C function depends on the calling convention used in its declaration:

Calling Convention	Decoration
__cdecl (the default)	Leading underscore (_)
__stdcall	Leading underscore (_) and a trailing at sign (@) followed by a number representing the number of bytes in the parameter list
__fastcall	Same as __stdcall, but prepended by an at sign instead of an underscore


I.2  Viewing Decorated Names

You can get the decorated form of a function name after you compile the source file that contains the function definition or prototype. To examine decorated names, you can either read the listing output from the compiler or run the DUMPBIN tool on the .OBJ (or a library containing the .OBJ).


Using a Listing to View Decorated Names

To get the decorated form of a function using a compiler listing, do the following:

1.	Use the /FAs or /Fc option to compile the source file containing the function definition or prototype.

2.	Find the undecorated function definition in the resulting listing.

3.	Examine the previous line. The label for the PROC NEAR command is the decorated form of the function name.


Using DUMPBIN to View Decorated Names

To get the decorated form of a function using DUMPBIN, run DUMPBIN on the .OBJ or .LIB using the /SYMBOLS option. Find the undecorated function definition in the output. The undecorated name is followed by the decorated name, each enclosed in parentheses.


I.3  Using Decorated Names

In most circumstances, you do not need to know the decorated name of a function. LINK and other tools can usually handle the name in its undecorated form.

However, certain situations require that you specify the name in its decorated form. You must specify the decorated name of C++ functions that are overloaded and special member functions such as constructor and destructor functions in order for LINK and other tools to be able to match the name. You must also use decorated names in assembly source files that reference a C or C++ function name.

Warning  If you change the function name, class, calling convention, any parameter, or the return type, the old decorated name is no longer valid. You must get the new version of the function name and use it everywhere the decorated name is specified.