Article ID: 126845 - Last Review: September 1, 2005 - Revision: 4.0 Description of C++ name decoration
This article was previously published under Q126845 On This PageSUMMARY The Microsoft C++ compilers encode the names of symbols in
C++ programs to include type information in the name. This is called "name
decoration," or "name mangling." The purpose of this is to ensure type-safe
linking. The C++ language allows function overloading where functions with the
same name are only distinguished from one another by the data types of the
arguments to the functions. Name decoration enables the linker to distinguish
between different versions of overloaded functions because the names of the
functions are encoded or decorated differently. MORE INFORMATION Different compiler vendors have their own methods or
algorithms for decorating names. Microsoft does not publish the algorithm its
compilers use for name decoration because it may change in the future. However,
it is sometimes necessary to get the decorated version of a function name. For
example, you may need to export a C++ function from a Windows DLL by listing it
in the EXPORTS section of a .DEF file used to build the DLL. (Although
declaring the function with __declspec( dllexport ) is the preferred method to
export a C++ function using Visual C++, 32-bit Edition, it is still valid to
use a .DEF file with these products.) To export the function successfully, you
need to list its decorated name, not the name in the source code. For all of the products listed above, Microsoft makes Browser Toolkits available. These toolkits provide functions that can interpret decorated names. For more information about __declspec(dllexport), click the following article number to view the article in the Microsoft Knowledge Base: 132044
(http://support.microsoft.com/kb/132044/
)
Using _declspec(dllimport) and _declspec(dllexport) in code
The following sample code uses the FormatDName function in the
browser library, part of the Browser
Toolkit.
To download the Browser Toolkit, visit the following Microsoft Web site:http://www.microsoft.com/downloads/details.aspx?FamilyID=621ae185-1c2a-4d6b-8146-183d66fe709d&displaylang=en
(http://www.microsoft.com/downloads/details.aspx?FamilyID=621ae185-1c2a-4d6b-8146-183d66fe709d&displaylang=en)
The
function returns the undecorated form of the name passed to it. Sample codeAPPLIES TO
| Other Resources Other Support Sites
CommunityArticle Translations |






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top