Help with implementing callback functions using ctypes

Nobody nobody at nowhere.com
Thu May 9 14:32:08 EDT 2013


On Wed, 08 May 2013 04:19:07 -0700, jamadagni wrote:

> I have the below C program spiro.c (obviously a simplified testcase)
> which I compile to a sharedlib using clang -fPIC -shared -o libspiro.so
> spiro.c, sudo cp to /usr/lib and am trying to call from a Python script
> spiro.py using ctypes. However it would seem that the first call to the
> callback results in a segfault.

> # call the C function
> spiro_to_bezier_strict ( src, len ( src ), bc )

This line should be:

  spiro_to_bezier_strict ( src, len ( src ), byref(bc) )

Without the byref(...), it will try to pass a copy of the structure rather
than passing a pointer to it.




More information about the Python-list mailing list