须要注意的是,方法调用的时候须要严格的对应,若是是使用_stdcall
修饰的方法,那么就只能用对应的类型的工具加载,若是不使用,极可能会出现找不到的现象。python
对于动态连接库的调试,官方文档给出了解决方案,使用faulthandler
模块来调试。工具
如何进行严格的传入类型声明。调试
restype argtypes
,前者声明返回类型,后者声明传入类型。案例一rest
#include<stdio.h> extern "C" int test(int n) { printf("hello test%d\n",n); return n; }
from ctypes import * handle = cdll.LoadLibrary("./test.dll") handle.test.restype = c_int handle.test.argtypes = [c_int] n = handle.test(22) print(n,type(n))