We have a Win32 console DLL that we currently compile with VS C++ 2003, but we need to be able to allow it to be linked to and used by executables compiled with VS C++ 2005. For the most part this works.
However, we have a couple of functions that take a std::exception as an argument, and these cannot be used in the 2005 executables because the name mangling is different. In 2003 the mangled name is:
and in 2005 it is:
Does anyone know of any way that we could control the way in which the names are mangled either in 2003 or 2005 to allow the function compiled by 2003 to be called in code compiled and linked by 2005 (We recognize that there may be a further problem, which is that the exception object itelf may be incompatible between the two compilers).
Thanks for any help anyone can give.

C++ name mangling change between 2003 and 2005
vx2929
Thanks for the suggestion! That will give us a work-around.
I do not think it is really a "bug". After posting that message I found an msdn article that states that exception was moved into std for 2005.
Thanks for the help!
fivewhy
Hmm, it doesn't seem to affect ofstream. When I switched to exception then it started giving the errors.
If you change it to using the c externals then it worked, but doing that you lose the ability to overload functions.
My test dll
#include <windows.h>
#include <exception>
using namespace std;
extern "C" __declspec(dllexport) BOOL Fun1(exception* os)
{
return TRUE;
}
My test app
#include <exception>
#include <windows.h>
using namespace std;
extern "C" __declspec(dllimport) BOOL Fun1(exception* os);
int main()
{
exception* ex = new exception();
Fun1(ex);
delete ex;
return 0;
}
If you notice, there is the extern "C" before the imported functions. This tell it that it will be using the C name mangling method not the C++ method. Doing this worked for me. Also, since you found the problem, report this as a bug to lab.msdn.microsoft.com with a small code sample that shows how to recreate the problem.
Kamal Hassan
For example:typedef std::exception exception;
Fabio moschetti
This is strange you know. Since I have no problems with cases like this. Using the stl I wrote a sample app that uses a dll compiled with vc++ 2003 and I was able to use it with no problems in a vc++ 2005 app.
The code I had for the test dll is as follows.
#include <windows.h>
#include <iostream>
#include <fstream>
using namespace std;
__declspec(dllexport) BOOL Fun1(ofstream* os)
{
os->write("hello", 6);
return TRUE;
}
The code I had for the test app is as follows.
#include <iostream>
#include <fstream>
#include <windows.h>
_declspec(dllimport) BOOL Fun1(std::ofstream* os);
using namespace std;
int main()
{
ofstream* tf = new ofstream();
tf->open("File1");
Fun1(tf);
tf->close();
delete tf;
return 0;
}
So could you post a code sample that reproduces this problem please.