为什么外部“C”?在以下情况下仍然无法删除名称修改
extern "C"
{
__declspec(dllexport) LRESULT CALLBACK MTest
}
使用depends,我发现即使使用extern“C”
仍然存在名称修改。
extern "C"
{
__declspec(dllexport) LRESULT CALLBACK MTest
}
Using depends , I found there is still name mangling even using extern "C"
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 __declspec(dllexport) 获得真正未修饰的名称的唯一方法是使用 __cdecl 调用约定导出它们。 CALLBACK 变成 __stdcall,它用前导 _ 和尾随 @bytes 修饰名称的“C”形式。
否则,您可以使用 .DEF 文件,这很痛苦。另一种 MSVC 特定方法是嵌入 /EXPORT 指令写入目标文件(或将其作为显式链接器设置传递)
由于某种原因,指令的
=
部分未在帮助中列出The only way to get truly undecorated names with __declspec(dllexport) is to export them with the __cdecl calling convention. CALLBACK becomes __stdcall, which decorates the "C" form of the name with a leading _ and trailing @bytes.
Otherwise you can use a .DEF file, which is a pain. Another MSVC specific way is to embed a /EXPORT directive into the object file (or pass it as a explicit linker setting)
For some reason the
=
part of the directive is not listed in the help这是名称修饰而不是破坏。您应该在 DEF 文件中声明未修饰的名称,然后您将获得您正在寻找的行为。
That's name decoration rather than mangling. You should declare the undecorated name in a DEF file and then you'll get the behaviour you are seeking.
作为一名视觉 C++ 程序员,我首先想到的是……“这些宏 LRESULT 或 CALLBACK 是否引入了标准调用约定?”损坏的名称是否有@NUMBER_OF_BYTES_OF_PARAMATER_LIST或描述附加到它们的实际类型的字符?
Not being much of a visual C++ programmer the first thought that occurs to me is ... "do any of those macros LRESULT or CALLBACK introduce the standard calling convention?" Do the mangled names have @NUMBER_OF_BYTES_OF_PARAMATER_LIST or characters depicting the actual types appended to them?