I have an x86 DLL project in Visual Studio Express 2012 that exports a number of __stdcall
functions. In x86, the MS linker tags each function name with an underscore prefix and a suffix consisting of an @
-sign followed by a number indicating the number of argument bytes the function pops from the stack when it returns.
e.g. My function declarations are written in C (OK, C++ with extern "C"
) and the are being mapped to exported symbol names like so:
__declspec(dllexport) int32_t __stdcall f()
→_f@0
__declspec(dllexport) void __stdcall g(int64_t)
→_g@8
I need to get rid of this decoration so I am only exporting f
, g
, and so on.
There are already questions on this topic here and here and the answers explain you need to use a .DEF file which you pass to the linker via the /DEF
switch.
So I made myself a .DEF file which looks like this:
EXPORTS
_f@0 = f
_g@8 = g
...
This is working, but only partially! In particular, the exported names have changed from _f@0
→ _f
, _g@8
→ _g
, and so on. So the '@#' decoration is gone but the leading underscore remains.
How do I get rid of the leading underscore!?