[Cython] Header file bug

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jun 8 00:24:33 CEST 2011


> On Sat, Jun 4, 2011 at 10:36 AM, Seth Shannin <sshannin at stwing.upenn.edu> wrote:
> 
>>test.h:11: warning: 'struct __pyx_obj_4test_foo' declared inside parameter
>>list
>>test.h:11: warning: its scope is only this definition or declaration, which
>>is probably not what you want

Not sure about Cython, but the way to to this in Pyrex
is to declare the class 'public' as well, and then the
struct declaration for it will be put in the .h file.

You will need to supply C names for the struct and type
object as well, e.g.

    cdef public class foo[type FooType, object FooObject]:
       ...

The generated test.h file then contains

    struct FooObject {
      PyObject_HEAD
      int a;
      int b;
    };

    __PYX_EXTERN_C DL_IMPORT(void) bar(struct FooObject *);
    __PYX_EXTERN_C DL_IMPORT(struct FooObject) *make_foo(int,int);

-- 
Greg


More information about the cython-devel mailing list