[Pyrex] when pyrex gets tough

Chris Mellon arkanes at gmail.com
Mon Sep 3 02:37:02 CEST 2007


On 9/2/07, David McNab <david at rebirthing.co.nz> wrote:
> On Mon, 2007-09-03 at 11:09 +1200, Greg Ewing wrote:
> > cdef extern from "yuv4mpeg.h":
> >
> >     ctypedef struct y4m_ratio_t:
> >        int n
> >        int d
> >
> >     y4m_ratio_t y4m_fps_NTSC_FILM
> >     y4m_ratio_t y4m_fps_FILM
> >     y4m_ratio_t y4m_fps_PAL
> 8><
>
> Well, that works just fine.
>
> Putting the extern'ed ratio struct constants into the 'cdef extern from'
> was just the voodoo I was looking for - it allows the generated C code
> to reference them, but doesn't declare them as vars - it correctly
> relies on the existing extern decs in yuv4mpeg.h.
>
> (Did I miss something when I was so impatiently reading the pyrex
> manual? Is this a special case worth adding to the manual?)
>

The section you wanted was here:

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/overview.html#ExternDecls

You can use this same technique for moving all sorts of C-defined
names into the pyrex namespace - you just need "enough" of a type
match that pyrex can generate working code for it.



More information about the Pyrex mailing list