Question

extern "C"
{
__declspec(dllexport) LRESULT CALLBACK MTest
}

Using depends , I found there is still name mangling even using extern "C".

Was it helpful?

Solution

The only way to get truly undecorated names with __declspec(dllexport) is to export them with the __cdecl calling convention. CALLBACK becomes __stdcall, which decorates the "C" form of the name with a leading _ and trailing @bytes.

Otherwise you can use a .DEF file, which is a pain. Another MSVC specific way is to embed a /EXPORT directive into the object file (or pass it as a explicit linker setting)

#pragma comment(linker, "/EXPORT:ExportSymbol=DecoratedName");

For some reason the = part of the directive is not listed in the help

OTHER TIPS

That's name decoration rather than mangling. You should declare the undecorated name in a DEF file and then you'll get the behaviour you are seeking.

Not being much of a visual C++ programmer the first thought that occurs to me is ... "do any of those macros LRESULT or CALLBACK introduce the standard calling convention?" Do the mangled names have @NUMBER_OF_BYTES_OF_PARAMATER_LIST or characters depicting the actual types appended to them?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top