If I declare a function like this:
#ifdef TEST_EXPORTS
#define TEST_API __declspec(dllexport)
#else
#define TEST_API __declspec(dllimport)
#endif
TESTAPI int __stdcall myadd(int a, int b);
The symbol in the DLL is _myadd@8, which makes perfect sense to me (after few hours of reading other questions here, that is).
But the windows libraries seem to do something different. They also use __stdcall (disguised as WINAPI), but the symbols in the DLLs have no name decoration. If the method above where in the windows libs, the symbol would be myadd.
My guess is that they use a def file to alias the symbols. But why does my linker know this when I link to one of these DLLs?
The windows header files declare these functions with WINAPI, so if I call them, the linker should look for the decorated name, as it is a __stdcall function. Yet somehow the linker knows to drop the name decoration.
I've tried to replicate this by writing a small DLL and removing the name decoration with a def file. As expected I get linker errors as the linker is still looking for the decorated name. I've done this in pure C, to make sure that c++ name mangling does not effect it.
edit: to clarify, MSVC 14.0 / VS2015, 32-bit

