我试图使用swig从python中使用以下原型访问C函数:
int cosetCoding(int writtenDataIn, int newData, const int memoryCells, int *cellFailure, int failedCell);
Run Code Online (Sandbox Code Playgroud)
Swig创建.so没有问题,我可以将它导入到python中,但是当我尝试使用以下内容访问它时:
cosetCoding.cosetCoding(10,11,8,[0,0,0,0,0,0,0,0],0)
Run Code Online (Sandbox Code Playgroud)
我得到以下回溯:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: in method 'cosetCoding', argument 4 of type 'int *'
Run Code Online (Sandbox Code Playgroud)
指针应该是一个int数组,其大小由memoryCells定义