[Pyrex] Newbie Missing a Fundamental Point?

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Jul 22 08:53:50 UTC 2006


Kent Borg wrote:
> It makes
> sense that I have to tell Pyrex what .h file to look in to know what
> the data structure is, but why do I need to also write a second
> definition in Pyrex?

I know it's not ideal, but for various reasons it would
be very difficult to make Pyrex automatically extract
all the information it needs from a .h file. A few
people are working on tools to help with the process,
but I doubt whether it will ever become fully automatic.
There's just too much messy stuff that can go on in a
.h file. You can blame it on C. :-)

One thing to note is that you don't have to include
every member of every struct, only the ones that you
actually refer to in Pyrex code. And if you don't refer
to the contents of a struct at all, you can probably
get away with just an opaque declaration for it with
no body at all.

Another thing is that you don't have to match every
variation on the basic types. E.g. if the wrapped code
uses a bunch of typedefs for different sizes of int,
often you can get away with just calling them all
'int' or 'unsigned int' in Pyrex. Since the C compiler
sees the original definitions in the .h file, it will
still generate the correct code.

Hope that helps,
Greg



More information about the Pyrex mailing list