Search code examples
c++dllname-manglingname-decorationstdcall

VC++ prevent all symbol name decorations


I'm working on a DLL which will be used from another language (so no import libs and including the dll's headers) using the _stdcall calling convetion. The problem is that VC++ seems to always do some name decoration on its exported symbols. All the references ive seen say use extern "C" but this still seems to leave me with a leading underscore, and a @ plus a number after the exported name.

The worst bit is the automated means of loading extension dll's in the target language essentially does "func_name = GetProcAddress(dll, "func_name")" so using an undecorated name GetProcAddress fails, and using the decorated name it complains of an illegal variable name (@ is not allowed) :(

How can I make VC++ export somthing with no name decorations at all?

extern "C" __declspec(dllexport) int __stdcall test(int x, const char *str);

dumpbin.exe

00011366 _test@8 = @ILT+865(_test@8)


Solution

  • You can use a .def file. It will let you export the functions without the decorations.

    Read: Exporting from a DLL Using DEF Files