Friday 15 June 2012

Pass a C Structure from Python using Ctypes -


I am trying to call a function in a C library which uses the structure as a parameter. How do I do this? In the same way, I have made a CTPP presentation of the structure in the document, but I am not working directly on it.

I have tried to find an example but all the examples I found have structures in pointers.

It is difficult to say without seeing your code, but my guess is that you have to instantize the structure. From the docs: CTIP import by importing

  class digits (structure): _fields_ = [("x", c_int), ("y", c_int)] point = point (10, 20)   

The last line point creates an example of called POINT structure.

This really helps if you can show the structure definition, how you are using it, and any error message

No comments:

Post a Comment