I want to pass the address of a numpy array buffer to c function, My C function looks like:
void print_float_buff(void *buff)
{
float *b = (float *)buff;
printf("Float Data: %f, %f, %f,\n", b[0], b[1], b[2]);
}
In python my code is:
import numpy as np
fun=ctypes.CDLL("./mylib.so")
l = np.array([10., 12.6, 13.5], dtype = 'float')
address, flag = l.__array_interface__['data']
fun.print_float_buff(ctypes.c_void_p(address))
A am getting completely different data in my c function. Address doesn't seem good. How can I pass correct address to my C function? Thanks.