[SPAM: 3.000] [Pyrex] size_t and reference passing in 64-bit platforms
Francesc Alted
falted at openlc.org
Sun Jan 11 14:23:18 CET 2004
Hi Michael,
Thanks for your suggestion, but this does not even compile. The next code:
--
# Ei!, emacs, this is -*-Python-*- mode
cdef extern from "stdlib.h":
#ctypedef int size_t
# The correct correspondence between size_t and a basic type is *long*
# instead of int, because they are the same size even for 64-bit platforms
#ctypedef long size_t
ctypedef size_t
cdef extern from "test_c.h":
size_t read_c(size_t *id)
def readC(size_t id):
cdef size_t id2
id2 = id
return read_c(&id2)
--
gives:
$ pyrexc test.pyx
test.pyx:11:24: Pointer base type cannot be a Python object
test.pyx:16:18: Cannot take address of Python variable
It seems like if size_t defined in that way is similar to object, i.e.:
cdef extern from "stdlib.h":
ctypedef size_t
whould be equivalent to
cdef extern from "stdlib.h":
ctypedef object size_t
which is not what we want.
A Divendres 09 Gener 2004 23:43, vareu escriure:
> On Sat, 2004-01-10 at 02:32, Francesc Alted wrote:
> > As size_t is not exactly a primitive type, I mapped it to a "int" type,
> > like in:
> >
> > cdef extern from "stdlib.h":
> > ctypedef int size_t
>
> Try
> cdef extern from "stdlib.h":
> ctypedef size_t
>
> This does not declare what "size_t" is, it just states that it is
> declared externally, somewhere. The code for declaring external
> structures is quite similar.
>
> Hope this helps,
> Michael
--
Francesc Alted
More information about the Pyrex
mailing list