对于数组(指针)类型的调用,比如int* 或者float* 等
C++中编写的dll函数
EXPORT void testtrans(float* arr, int n)
{
for (int i = 0; i < n; i++)
{
printf("%f ", arr[i]);
}
}
Python对其进行调用时
data = [1.0,3.5,2.7,8.7,1.1]
cdll = LibraryLoader(CDLL)
dll = cdll.LoadLibrary(dll_path)
testtrans = dll.testtranstesttrans.argtypes = [POINTER(c_float),c_int]
CFLOAT = (c_float*len(data))(*data)
cast(CFLOAT, POINTER(c_float))
testtrans(CFLOAT,c_int(len(data)))