我需要将 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'>
谢谢。