I have a function in a DLL that I have to wrap with python code. The function is expecting a pointer to an array of doubles. This is the error I\'m getting:
LP_c_double is created dynamically by ctypes when you create a pointer to a double. i.e.
LP_c_double = POINTER(c_double)
At this point, you've created a C type. You can now create instances of these pointers.
my_pointer_one = LP_c_double()
But here's the kicker. Your function isn't expecting a pointer to a double. It's expecting an array of doubles. In C, an array of type X is represented by a pointer (of type X) to the first element in that array.
In other words, to create a pointer to a double suitable for passing to your function, you actually need to allocate an array of doubles of some finite size (the documentation for ReturnPulse should indicate how much to allocate), and then pass that element directly (do not cast, do not de-reference).
i.e.
size = GetSize()
# create the array type
array_of_size_doubles = c_double*size
# allocate several instances of that type
ptrpulse = array_of_size_doubles()
ptrtdl = array_of_size_doubles()
ptrtdP = array_of_size_doubles()
ptrfdl = array_of_size_doubles()
ptrfdP = array_of_size_doubles()
ReturnPulse(ptrpulse, ptrtdl, ptrtdP, ptrfdl, ptrfdP)
Now the five arrays should be populated with the values returned by ReturnPulse.