[Pyrex] creating and populating Python/C structs
Simon Burton
simon at arrowtheory.com
Sun Sep 4 16:41:47 CEST 2005
It seems you need to include compile.h before frameobject.h (see attached).
Simon.
On Sun, 4 Sep 2005 14:58:58 +1000
Christopher Armstrong <radeex at gmail.com> wrote:
> Hi all,
>
> I'm trying to write a small function to create Python Frame objects
> from Python code. I've been having problems getting everything
> working. I can get pyrex to compile to C well enough, but gcc is
> barfing on compiling the C. I've been reading through the available
> documentation, but haven't found anything enlightening. It seems
> dealing with Python/C API *objects* (as opposed to functions) isn't
> something that's done often?
>
> Basically, I'm doing a cdef extern from *: and then declaring the
> PyFrameObject struct like so:
>
> # Just defining the members that we need to manipulate
> struct _frame:
> _frame *f_back
> PyCodeObject *f_code
> PyObject *f_builtins
> PyObject *f_globals
> PyObject *f_locals
> PyObject *f_exc_type, *f_exc_value, *f_exc_traceback
> int f_lineno
> ctypedef _frame PyFrameObject
>
> later, in a newframe function, I'm doing this to create the new frame object:
>
> cdef PyFrameObject *frame
>
> When I try to compile the resulting C code, I get the following error:
>
> _tbconstruct.c: In function `__pyx_f_12_tbconstruct_newframe':
> _tbconstruct.c:57: error: `__pyx_v_frame' undeclared (first use in
> this function)
>
>
> I've attached the code (it's very short). I'm compiling it with
> pyrexc _tbconstruct.pyx; gcc -c -fPIC -I/usr/include/python2.4
> _tbconstruct.c
>
>
> Thanks for any help.
> --
> Twisted | Christopher Armstrong: International Man of Twistery
> Radix | -- http://radix.twistedmatrix.com
> | Release Manager, Twisted Project
> \\\V/// | -- http://twistedmatrix.com
> |o O| |
> w----v----w-+
>
--
Simon Burton, B.Sc.
Licensed PO Box 8066
ANU Canberra 2601
Australia
Ph. 61 02 6249 6940
http://arrowtheory.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: _tbconstruct.pyx
Type: application/octet-stream
Size: 1160 bytes
Desc: not available
Url : http://lists.copyleft.no/pipermail/pyrex/attachments/20050904/146f12b3/_tbconstruct.obj
More information about the Pyrex
mailing list