I'm trying to use a C function copyDataContent
that copies float data from a C struct object I point to with pointer DataHandle
into a location given by a float pointer. I have included the function prototype for this function. I can get the dimensions of this data via another function in the library. My code is below.
Prototype of copyDataContent
void copyDataContent(DataHandle DataSource, float* Destination);
Here's where things go wrong:
data = createData()
size0 = getDataPropertyInt(data,0)
size1 = getDataPropertyInt(data,1)
arrC = C.POINTER(C.c_float*size0*size1)
libc.copyDataContent.argtypes = [DataHandle,C.POINTER(C.c_float)]
libc.copyDataContent(data,arrC)
Console output:
ArgumentError: argument 2: <class 'TypeError'>: expected LP_c_float instance instead of _ctypes.PyCPointerType
^from the line where I actually call copyDataContent
But here's what the console tells me about arrC
arrC
Out[88]: __main__.LP_c_float_Array_0_Array_0
Can anyone shed any light on what is going wrong? ctypes docs aren't helping
arrC = C.POINTER(C.c_float*size0*size1)
creates a type not an instance.
If you want the instance of an array, use arrC = (C.c_float*size0*size1)()
.
to pass it to a float*
parameter, use libc.copyDataContent(data,cast(arrC,POINTER(c_float)))
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments