Unmangling C++ DLL Function Names -


possible duplicate:
how stop name-mangling of dll's exported function?

i have dll written in c++. exported function names need unmangled. example, int myfunc( int param1, int param2 ); needs appear outside application trying call library function myfunc. however, when @ using dependency walker, looks _myfunc@8. how have declared in c++:

extern "c" __declspec(dllexport) int winapi myfunc( int param1, int param2 ); 

i thought extern "c" trick. how rid of mangling? thanks.

ways rid of mangling: (assuming msvc build environment)

export via .def file.

export extern "c" ensuring __cdecl calling convention used. __stdcall prepends _ , postpends @ on dll exported functions when extern "c" used.

extern "c" __declspec(dllexport) int __cdecl myfunc(int param1, int param2); 

export using #pragma directive. need pass mangled name on other side of this. __funcdname__ useful directive put in macro in function list decorated name,

#pragma comment(linker, "/export:myfunc=_myfunc@8"); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -