I am writing a Cython wrapper around a C library we are maintaining. I am getting the following error message:
analog.pyx:6:66: Cannot convert 'unsigned short (*)' to Python object
Here's the code I am trying to write:
cimport company as lib
def get_value(device, channel, index):
cdef unsigned short aValue
err = library_get_data_val(device, channel, index, &aValue) # line 6
# Ignore the err return value for StackOverflow.
return aValue
The prototype of the C function I am trying to use is:
unsigned long library_get_data_val(unsigned long device, int channel,
int index, unsigned short *pValue);
The library function returns the requested value in the aValue
parameter. It's just an unsigned short
primitive. What's the expected way of returning primitives (i.e. not struct
) from these type of functions? I am new to Cython so the answer may be quite simple but I didn't see anything obvious through Google.