c++类中公共函数的地址
Address of a public function from a C++ class
我的应用程序需要从C程序调用部分c++代码。
当我必须获得公共函数的地址时,问题就出现了。
我不知道如何从类中获取公共函数的地址。我特别需要地址,以便我可以将地址作为函数指针传递。
我们也欢迎任何其他绕过该解决方案的解决方案。
我试过静态铸造,但它没有工作。
static_cast<izot_events*>(thisizot_events)->myIzotWink()
调用函数,但我对地址感兴趣。
我试过使用
static_cast<izot_events*>(thisizot_events)->myIzotWink
但是这会返回一个错误。
这里还有一些代码供参考。
void* C_Create() { return new izot_events(); }
thisizot_events = C_Create();
static_cast<izot_events*>(thisizot_events)->myIzotWink // This does not work i.e I cant get the value.
static_cast<izot_events*>(thisizot_events)->myIzotWink() // While this gets called
将函数设置为静态,然后可以执行&MyClass::my_function。你不应该做任何铸造;相反,让你的静态函数有正确的声明来匹配函数指针的类型。
相关文章:
- 为什么成员函数地址离自由函数这么远?
- MFC 消息映射中的函数地址
- 设置成员 GlobalCEFApp->OnWebKit使用函数地址初始化 C++生成器
- 在Visual C 中找到调用函数地址(安全)
- 获取函数地址时出现奇怪行为
- 函数地址
- 如何在C++中打印成员函数地址
- 为什么函数指针、函数地址和函数相同
- 匹配布尔值与常量 void* 重载的函数地址
- 函数地址和函数地址的地址没有区别吗?
- 在 Linux 库中查找静态函数地址
- 调用传递给 gcc 内联汇编器 (avr-gcc) 的 const 函数地址
- 使用32位应用程序从64位kernel32.dll获取函数地址
- 为什么函数地址不是常量表达式
- 将函数地址转换为 64 位整数:未定义/行为不当
- Visual Studio在打印函数地址时出错
- 获取有关函数地址的信息
- 通过函数地址调用另一个类的函数
- 打印成员函数地址的最简单方法是什么?
- 圆括号成员函数地址错误