Click here to Skip to main content
13,591,515 members
Click here to Skip to main content
Add your own
alternative version


11 bookmarked
Posted 24 Jun 2007
Licenced CPOL

Mangling issues - VC 6.0 and VC 8.0

, 24 Jun 2007
Rate this:
Please Sign up or sign in to vote.
How mangling changes in VC++ 6.0 and VC 8.0 can cause problems in your existing application and how to solve it.


We all know that mangling or name decoration is compiler specific. And the new VC 8.0 is no different. They have come up with a new mangling scheme which created problems in one of our recent projects. The issue was because of the difference in mangling scheme these compilers have. Well, I won't get into the details of the VC 8.0 mangling scheme here. But what if there is a situation wherein you have to use an MFC extension DLL built using VC 8.0, in a VC 6.0 project?

Problem Description

We have an MFC extension DLL (a DLL from which you can export a class) built using VC 8.0, and we want to use that DLL in a VC 6.0 project. Now, if I want to use that extension DLL in my VC 6.0 project, all that I need to do is to add the header file in which we have the class and its member declaration and the lib file that will be used during linking time.

We expect everything to go well, but when you build the VC 6.0 application, you will get an error saying unable to link to a class member function which we are calling from our VC 6.0 application. The problem here is VC 6.0 will create a mangled version of the class member function which we have specified in the header file and it will try to match with the one in the lib file. Unfortunately, the decorated version of your lib and the one which is generated by VC 6.0 do not match.

How do we solve this? In the MSDN article titled 'Old-Style Name Mangling for Exported Template Instantiations', Microsoft suggests a way to include both mangling schemes in the linker command line option. In-order to do that, we have to identify the mangled version of the class member function from the lib, by dumping the exports or opening it in Notepad and the VC 6.0 generated mangled version (which you will get as a linker error when you build your VC 6.0 application ;-) ). Include this along with the VC 8.0 generated mangled version of the member function which you are trying to call.

For example:

/export: <VC 6.0 decorated version>=<VC 8.0 decorated version>

Save it and build the application. Now your lib will generate two decorated versions for the same class member function, one based on the VC 6.0 mangling scheme (which we got as a linker error) and the other based on the VC 8.0 mangling scheme (which we identified by checking the lib). Now use this lib and build the VC 6.0 application. You should be able to successfully link the application.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
A Software Engineer working on C++, VC++, MFC and .Net Compact Framework.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180618.1 | Last Updated 25 Jun 2007
Article Copyright 2007 by kris_raj
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid