C ++:找出装饰名字 [英] C++ : Finding out decorated names

查看:190
本文介绍了C ++:找出装饰名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到将被分配给每个方法名称的装饰名称?我试图找出装饰的名字,以便我可以在DLL中导出它。

How can I find out the decorated name that will be asigned to each method name ? I'm trying to find out what the decorated name is , so that I may export it , in a DLL .

推荐答案

。 DEF文件正在使用



忘记.DEF文件。他们是过去的事情。

.DEF file are still being used?

Forget .DEF files. They are a thing of the past.

通过__declspec(dllimport / dllexport)导出您的函数,即C函数或C ++符号。

Export your functions, be them C functions or C++ symbols, through __declspec(dllimport/dllexport).

如果您真的需要未装饰的名称,请使用Greg Hewgill,__declspec(dllimport / dllexport)关键字的建议,结合externC,将剥离其装饰符号...

If you really need undecorated names, use as suggested by Greg Hewgill, the __declspec(dllimport/dllexport) keywords, combined with extern "C", which will strip those symbols of their decoration...

有一些有效的原因:你想导出将被C代码使用的代码,或者您想使用不同编译器编译的模块使用DLL。

There are some valid reasons for that: You want to export code that will be used by C code, or you want to use your DLL from modules compiled with different compilers.

而第二个原因,我会产生一个DLL,每个编译器,并保持装饰。

And for the second reason, I would instead produce one DLL per compiler, and keep the decorations.

除了这些原因,为什么要删除装饰?

Aside those reasons, why do you want the decorations removed?

恰恰相反。

如果你正在使用一个编译器(我认为你这样做,因为你想使用装饰的名字,而不是externC的那些),然后保持C ++的装饰/名称变得简单。

If you are working with one compiler (and I suppose you do, because your want to use the decorated names, not extern "C" ones), then keep the C++ decoration/name mangling.

这样,你可以使用完整的C ++电源,即命名空间,类,函数/方法重载等。

In this way, you'll be able to use full C++ power, that is, namespaces, classes, function/method overloads, etc..

仍然是用符号装饰手动玩是一个食谱灾难:使用dllexport导出您的符号,而无需处理另一个(.DEF)文件。

Still, playing manually with symbol decorations is a recipe for disaster: Use dllexport to export your symbols without having to deal with yet another (.DEF) file.

这篇关于C ++:找出装饰名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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