CTYPES:过程可能调用了太多参数(超出了92个字节)

CTYPES:过程可能调用了太多参数(超出了92个字节),第1张

CTYPES:过程可能调用了太多参数(超出了92个字节)

如果使用的是 windll.LoadLibrary ,请尝试改用 CDLL

来自网络:“该函数的调用约定是x86 cdecl,但是您使用的是x86 stdcall约定(WinDLL)。”
如果您使用的是32位Python,则可能是约定俗成的问题。

对于这样的C函数:

__declspec(dllexport) int __cdecl wrp_testchar(int steps, double in_data[], char* in_char )

python代码必须是:

N = 2from ctypes import *# Load the library hllDll = CDLL("testchar.dll") wrp_testchar = hllDll.wrp_testchar # Specify the parameter and return types hllDll.wrp_testchar.argtypes = [POINTER(c_int), POINTER(c_double * N), c_char_p]# Next, set the return types... hllDll.wrp_testchar.restype = c_intsteps = (c_int)(2)in_data = (c_double * N)() in_data[0] = float(1) in_data[1] = float(1)in_char = (c_char_p)(b'Helloworld')a = int(0)# Call function a = wrp_testchar(byref(steps), byref(in_data), in_char)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5617590.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存