8

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)

agf
  • 171,228
  • 44
  • 289
  • 238
SyncViews
  • 125
  • 1
  • 5
  • is there a reason of using stdcall instead of cdecl? – CharlesB Jul 11 '11 at 11:55
  • 1
    Which language are you targeting ? Why does `GetProcAddress` fail, it returns the address of the function not the name and I don't know any programming languages that forbid the use of a '@' in strings – Djole Jul 11 '11 at 11:56
  • see http://stackoverflow.com/q/4550294/11343 – CharlesB Jul 11 '11 at 11:58

1 Answers1

6

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

Read: Exporting from a DLL Using DEF Files

Eran
  • 21,632
  • 6
  • 56
  • 89
  • This seems to do what I want and I guess is what other dll's do rather than using __declspec. Would be nice if it could be done with __declspec, but since I'm having to maintain a list for the auto-importing later having one in a .def is not that much extra work. – SyncViews Jul 11 '11 at 12:23