How to use float ** from C in Python? -


After no success with

My question, I started may not be the weapon of choice swig thinking that Gave. I need binding for some functions. One of these tasks takes a float **. What would you recommend? Ctypes

interface file:

  extern int read_data (const char * file, int * n_, int * M_, boat ** data_, int ** classes_);  

I have been using ctypes for several projects now with the results are quite happy I do not think I personally just need a pointer-to-pointer cover, but, in theory, you should be able to perform the following tasks: from ctypes import * your_dll = Cdll

 . LoadLibrary ( "your_dll.dll") PFloat = pointer (C_float) pint = pointer (c_int) p_data = PFloat () p_classes = Pint () buff = create_string_buffer (1024) n1 = c_int (0) n2 = c_int (0) retired = Your_dllkread_data (buff, ByRef (n1), ByRef (N 2), ByRef (p_data), ByRef (p_classes)) print ( 'Data:', p_data.contents) print ( 'class:', p_classes.contents) < / Code> 

Comments