【发布时间】:2018-07-16 08:50:02
【问题描述】:
例如我有一个 C++ 变量声明和这样的函数(假设它是一个 dll 函数)
int img_width,img_height,步幅; 一些功能(&img_width,&img_height,&stride) { …… }我们如何使用 python ctypes 做同样的事情?
我尝试了以下方式
img_width, img_height, 步幅 = c.POINTER(c_int), c.POINTER(c_int), c.POINTER(c_int) dll.somefunction(img_width,img_height,步幅)导致以下异常
ctypes.ArgumentError: 参数 1: : 不知道如何转换参数 1)我也尝试过以下方式
dll.somefunction.restype = c.c_void_p dll.somefunction.argtypes = [c.POINTER(c_int), c.POINTER(c_int), c.POINTER(c_int)] dll.somefunction(img_width,img_height,步幅)我最终遇到以下异常
NameError:未定义全局名称“img_width”【问题讨论】:
标签: c++ python-2.7 ctypes