[Pyrex] cdef object in cdef class: Segmentation fault
Simon Burton
simon at arrowtheory.com
Wed Jan 14 01:55:04 CET 2004
On Tue, 13 Jan 2004 16:13:20 -0800
Paul Prescod <paul at prescod.net> wrote:
> Simon Burton wrote:
>
> > So far I have had no luck wrapping structs with c extension classes :(
> Maybe I misunderstand your question.I don't see any use of "structs" in
> this code. What do you mean by struct?
I have some rather large examples using structs. However this small example
still blows.
>
> Where is the definition of the C struct type?
>
> Here's some code I've used to deal with structs.
>
> http://www.prescod.net/python/pyrexopt/pyxpat/pyxpat.pyx
>
> cdef extern from "expat/expat.h":
> cdef struct XML_ParserStruct
> cdef XML_Parser XML_ParserCreate(XML_Char *encodingName)
>
>
> cdef class ExpatParser:
> cdef XML_Parser _parser
>
> def __init__(self, char *encoding):
> self._parser = XML_ParserCreate(encoding)
>
> Does that help?
>
>
> Paul Prescod
>
>
Yes, this is the technique I have tried. Also, I have seen other code examples similar to yours.
arrow:~/home/python/pyrex/bomb$ make
pyrexc -I/usr/include/python2.2 bomber.pyx
gcc -I. -I/usr/include/python2.2 -g -c bomber.c
ld -shared -o bomber.so bomber.o -lc -lm
python -c "import bomber"
EOF
make: *** [bomber.so] Segmentation fault
make: *** Deleting file `bomber.so'
arrow:~/home/python/pyrex/bomb$
Bye,
Simon.
--
Simon Burton, B.Sc.
Licensed PO Box A66
ANU Canberra 2601
Australia
Ph. 02 6249 6940
http://arrowtheory.com
More information about the Pyrex
mailing list