Hi all,
I'm getting a cython build[1] error[2] from the following code snippet[3].
A test file[4] using a similar implementation (stack memory only) built fine.
Could you help me see what I'm doing wrong here.
I'm using repo: cython-devel changeset: 2094:bcc850a1253a date: Mon
Jul 20 15:40:26 2009 -0700
Thanks ~Pete
[1] ####### build.sh script ##########
cython -a -I/home/travlr/src/numpy.gitsvn/doc/cython/ "$1"
gcc -shared -pthread -fPIC -fwrapv -O2 -Wall -fno-strict-aliasing -std=c99\
-I/usr/include/python2.6 -o ${1%\.*}.so ${1%\.*}.c
######## end build.sh script ########
[2] ######## build error message ########
$ ./build utils.pyx
Error converting Pyrex file to C:
------------------------------------------------------------
void* mmalloc(size_t size, size_t n_items):
cdef:
MemPoolItem* mp_cur = <MemPoolItem*>malloc(sizeof(MemPoolItem))
mp_cur.memory = malloc(size * n_items)
mp_cur.next = mp_head
^
------------------------------------------------------------
/home/travlr/py/cy/utils.pyx:14:29: Cannot convert Python object to
'MemPoolItem *'
[...]
######## end build error message ###########
[3] ######## code snippet #########
from defs cimport *
cdef:
struct MemPoolItem:
void* memory
MemPoolItem* next
MemPoolItem* mp_head=NULL
void* mmalloc(size_t size, size_t n_items):
cdef:
MemPoolItem* mp_cur = <MemPoolItem*>malloc(sizeof(MemPoolItem))
mp_cur.memory = malloc(size * n_items)
mp_cur.next = mp_head
mp_head = mp_cur
return mp_cur.memory
mfree():
cdef:
MemPoolItem* mp_cur = mpi_head
MemPoolItem* mp_tmp = NULL
while mp_cur:
free(mp_cur.memory)
mp_cur.memory = NULL
mp_tmp = mpi_cur.next
free(mpi_cur)
mp_cur = mpi_tmp
mp_head = NULL
######## end code snippet #########
[4] ######## test file #########
cdef:
struct S_t:
int val
S_t* next
S_t s
_run():
s.val = 345
print s.val
def run():
_run()
########### end test file ############
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev