我需要将 c++ dll 包装到 python。我正在ctypes
为此使用模块。
c ++标头类似于:
class NativeObj
{
void func();
}
extern "C"
{
NativeObj* createNativeObj();
}; //extern "C"
我想NativeObj
在 python 代码中创建,然后调用它的func
方法。
我写了这段代码并获得了指向NativeObj
但我没有找到如何访问func
>>> import ctypes
>>> d = ctypes.cdll.LoadLibrary('dll/path')
>>> obj = d.createNativeObj()
>>> obj
36408838
>>> type(obj)
<type 'int'>
谢谢。