[Cython] Header file bug

Seth Shannin sshannin at stwing.upenn.edu
Wed Jun 8 03:51:46 CEST 2011

Ah, that's what it means.  I saw something similar to this somewhere in
some documentation, but the object keyword threw me off.  To me,
'object' indicates something more on the python side than on the c side.

Also, even though you can do this to ensure the struct declaration ends
up in the header file, I would still make the case that currently
something is a bit off in that the header file tries to use something
which it has no information about (and in the process actually ends up
creating its own empty struct type).

Thanks for all the help.


On 06/07/2011 06:24 PM, Greg Ewing wrote:
>> 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);

More information about the cython-devel mailing list