dll导出功能名称问题 [英] a dll export function name question

查看:136
本文介绍了dll导出功能名称问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void  extern "C"  __declspec(dllexport) /*__cdecl*/ Run(HWND hWnd);
//(__cdecl by default)
the function name changed to "Run"


但是为什么不"_Run"?
根据 http://msdn.microsoft.com/en-us/library /aa235575(v=VS.60).aspx [ ^ ]

__cdecl会将函数名称更改为"_FunctionName".
为什么????


BUT Why not "_Run" ?
according to http://msdn.microsoft.com/en-us/library/aa235575(v=VS.60).aspx[^]

__cdecl will change the function name to "_FunctionName."
Why ????

推荐答案

下划线就是所谓的调用约定名称修饰.但是下划线被删除,因此您可以重新获得原始名称.您真的不必为此担心.

祝你好运!
The underscore is so called calling convention name mangling. But the underscore is removed so you get the original name back. You don''t really have to worry about it.

Good luck!


由于extern "C",下划线被删除了.
extern "C"删除所有名称修饰.
The underscore is removed because of extern "C".
extern "C" removes all name decorations.


这称为名称修饰.这说明了它是如何完成的以及用于什么目的: http://en.wikipedia.org/wiki/Name_mangling [ ^ ].

即使extern"C"提供了一个解决方案,我还是更喜欢使用替代方法:忽略该问题,并在使用DLL时按原样使用错误的名称(如果您使用其他语言来使用它,则可能会出现问题).您只需要了解错误的名称,然后在引用可执行模块时就对其进行冗长的使用.

为此,请使用二进制转储实用程序,例如Microsoft DUMPBIN.EXE http ://msdn.microsoft.com/zh-CN/library/c1h23y6c(v = vs.71).aspx [
This is called name mangling. This explains how it is done and for what purposes: http://en.wikipedia.org/wiki/Name_mangling[^].

Even though extern "C" provides a solutions, I prefer using the alternative: ignore the problem and use mangled names as is when you use the DLL (which could seem a problem if you''re using it with some different language). You just need to learn what a mangled name is and use it verbosely in referencing executable module.

To do it, use a binary dump utility, such as Microsoft DUMPBIN.EXE http://msdn.microsoft.com/en-us/library/c1h23y6c(v=vs.71).aspx[^].

—SA


这篇关于dll导出功能名称问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆