2
我需要將C++ dll封裝到python。我正在使用模塊。訪問ctypes返回對象的方法
C++頭是喜歡的東西:
class NativeObj
{
void func();
}
extern "C"
{
NativeObj* createNativeObj();
}; //extern "C"
我想在Python代碼來創建NativeObj
,然後調用其func
方法。
我寫了這個代碼,並獲得指針NativeObj
,但我沒有找到如何訪問func
>>> import ctypes
>>> d = ctypes.cdll.LoadLibrary('dll/path')
>>> obj = d.createNativeObj()
>>> obj
36408838
>>> type(obj)
<type 'int'>
感謝。