【发布时间】:2019-07-29 22:31:01
【问题描述】:
我正在使用 ctypes 加载 C 库(@987654321@ 文件)。然后我设置参数并调用一个函数并得到以下错误;
ctypes.ArgumentError: argument 4: <class 'TypeError'>: expected LP_c_ushort instance instead of _ctypes.PyCSimpleType
我猜它与第 3 行末尾的 POINTER 定义有关。你能帮忙吗?
import ctypes
mylib = ctypes.cdll.LoadLibrary('./libfocas32.so')
mylib.cnc_allclibhndl3.argtypes = ctypes.c_wchar_p, ctypes.c_ushort, ctypes.c_long, ctypes.POINTER(ctypes.c_ushort)
mylib.cnc_allclibhndl3.restype = ctypes.c_long
h = ctypes.c_ushort
ret = mylib.cnc_allclibhndl3('192.168.1.1',9000,1,(h))
【问题讨论】:
标签: python arguments function-pointers ctypes