ctypes

    0热度

    1回答

    我在Python 3中使用​​(作为c导入)来执行C++共享库。该库使用装入蟒蛇: smpLib = c.cdll.LoadLibrary(os.getcwd()+os.sep+'libsmpDyn.so') 功能之一有extern 'C'声明const char* runSmpModel(...)。 Python函数原型进行编码和运行:精美 proto_SMP = c.CFUNCTYPE(c

    0热度

    1回答

    我使用ctypes调用dll来读取存储区的内容。但它返回一个无符号的char指针,我想要获取指针的内容。怎么做我这么做? from ctypes import * c = WinDLL("FT_ET99_API.dll") hwnd = c_void_p() c.et_OpenToken(byref(hwnd), c_char_p('53E00FD8'), c_int(1)) c.et_

    1热度

    2回答

    我想共享使用多处理模块的sharedctypes部分的进程之间的一些字符串。 TL; DR: 我希望把我的琴弦成sharedctypes阵列,像这样: from multiprocessing.sharedctypes import Array Array(ctypes.c_char, ['a string', 'another string']) 更多信息: 的docs有这样一个字条:

    0热度

    1回答

    以下是C函数para_trans_test。 void para_trans_test(char x [] [100]) { strncpy(x[0],"zzz",100); } 以下是不起作用的python代码。 lib.para_trans_test.argtypes= [ctypes.POINTER(ctypes.c_char_p)] numParams=2 L=num

    0热度

    2回答

    我正在使用外部提供的ctypes结构,它有一些字段定义为通用捕获所有字段。所述data字段的类型是基于mode字段的值,如本示例所示: CONTAINS_ONE_FLOAT = 1 class TestStruct(ctypes.Structure): pass TestStruct._fields_ = [ ('mode', ctypes.c_uint32),

    1热度

    1回答

    我一直在通过ctypes将一些C++类扩展为python。 我首先尝试通过GDB和代码验证地址不等于NULL。它确实不等于NULL。我尝试通过printf打印指针,并将地址输出,但涉及指针的下一行代码会引发分段错误。奇怪的是,如果没有这个printf语句,printf语句后面的下一行代码将会工作。然而,涉及指针的下一个函数会像printf一样引发一个分段错误。 这里是我的参考代码: C++ - “

    0热度

    1回答

    当python通过ctypes调用导出的C++函数时,我得到访问冲突。 我将问题范围缩小到下面的C++函数:(上vs2017编译) #include <cstdio> __declspec(dllexport) void x() { FILE* out = stdout; // After debugging, this is where the access violation h

    -1热度

    3回答

    在下面的例子中,我试图让m个可变的地址,但它显示错误 >>> import ctypes >>> m = 1 >>> ctypes.addressof(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: invalid type >>> >>> >>> class

    1热度

    1回答

    所以我的问题是,我试图将图像数据转换为连续数组传递给C库,但由于某种原因,numpy给太长的数组分段错误。看一下例子 data = np.ascontiguousarray(np.array([1]*10000, dtype=np.float32)/255).ctypes.data_as(POINTER(c_float)) print data.contents.value # ok dat

    1热度

    1回答

    我使用痛饮生成我的C库,例如: mylib.py和_mylib.pyd int func(uint8_t* a) { return *a; } 在python: import mylib import ctypes a = (ctypes.c_uint8 * 8)() mylib.func(a) 但在运行的Python给我一个错误:TypeError: in metho