ctypes or struct from an h file

Is there a way that Python and C can have a shared definition for a binary data structure?
It could be nice if: 1. struct or ctypes had a function that could parse a .h/.c/.cpp file to auto-generate constructors or 2. a ctypes definition could be exported to a .h file.
So my question is - is there a way to do this in the std-lib or even pypi?
--yuv
ps If this doesn't exist, then I'm probably going to open a project and would like some tips/ideas.

2009/10/18 Yuvgoog Greenle ubershmekel@gmail.com:
Is there a way that Python and C can have a shared definition for a binary data structure?
It could be nice if:
- struct or ctypes had a function that could parse a .h/.c/.cpp file
to auto-generate constructors or 2. a ctypes definition could be exported to a .h file.
So my question is - is there a way to do this in the std-lib or even pypi?
No, not in the stldlib. There is a tool which read .h files and converted them to ctypes code, but I'm not sure of its status.
BTW, please ask questions like this on python-list next time.

Please nobody reply to this thread, I'm forwarding to python-list.
On Sun, Oct 18, 2009 at 8:42 PM, Benjamin Peterson benjamin@python.org wrote:
2009/10/18 Yuvgoog Greenle ubershmekel@gmail.com:
Is there a way that Python and C can have a shared definition for a binary data structure?
It could be nice if:
- struct or ctypes had a function that could parse a .h/.c/.cpp file
to auto-generate constructors or 2. a ctypes definition could be exported to a .h file.
So my question is - is there a way to do this in the std-lib or even pypi?
No, not in the stldlib. There is a tool which read .h files and converted them to ctypes code, but I'm not sure of its status.
BTW, please ask questions like this on python-list next time.
-- Regards, Benjamin
participants (2)
-
Benjamin Peterson
-
Yuvgoog Greenle