c ++类及其成员函数的名称调整? [英] Name mangling of c++ classes and its member functions?

查看:146
本文介绍了c ++类及其成员函数的名称调整?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法,我可以避免C ++类和其成员函数暴露时从c ++ dll名称调整。

Is there no way I could avoid name mangling of C++ classes and its member functions when exposed from a c++ dll.

我不能在这方面使用def文件机制吗?

Can't I use a def file mechanism in this regard ?

推荐答案

我认为最好的方法是在C ++库的周围提供C包装。这是非常受欢迎的10年或更多年前,当我在C ++编程,但我不知道是否做了任何更多。

I think the best way to do this is to provide C wrappers around the C++ library. This was quite popular 10 or more years back when I was programming in C++ but I don't know if it is done any more.

基本上,对于每个 class C ,为每个构造函数 ctor 暴露创建 externCCPtr cCtor ...)方法返回一个不透明的指针 CPtr 和每个函数 func 被暴露你创建 externCcFunc(CPtr,....)

Basically, for every class C, for every constructor ctor to be exposed to create an extern "C" CPtr cCtor(....) method that returns an opaque pointer CPtr and for every function func to be exposed you create extern "C" cFunc(CPtr,....)

另一种方法是创建具有函数指针类型的成员变量的 CStruct ,实现它们来调用类方法,让客户端做所有的努力。

Another approach is to create a CStruct that has member variables of function pointer types, implement them to call the class methods and let the client do all the hard work.

这篇关于c ++类及其成员函数的名称调整?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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