Dear all,
I experience problems with callbacks declared with the __stdcall
calling convention and custom data types as return type. To show the
problem I modified the cython callback demo cheese.pyx, other files
are the same like in
http://hg.cython.org/cython-devel/file/2137466cab4a/Demos/callback
cheese.pyx:
<<<<<<<<<<<<<<<<<<<<<<<<
cdef extern from "cheesefinder.h":
ctypedef void myvoid
ctypedef myvoid (__stdcall *cheesefunc)(char *name, void
*user_data) #this gives 'Syntax error in ctypedef statement'
#ctypedef void (__stdcall *cheesefunc)(char *name, void *user_data) #OK
void find_cheeses(cheesefunc user_func, void *user_data)
def find(f):
find_cheeses(callback, <void*>f)
cdef void __stdcall callback(char *name, void *f):
(<object>f)(name)
>>>>>>>>>>>>>>>>>>>>>>>
This produces a cython syntax error:
<<<<<<<<<<<<<<<<<<<<<<
cdef extern from "cheesefinder.h":
ctypedef void myvoid
ctypedef myvoid (__stdcall *cheesefunc)(char *name, void *user_data) #this g
ives 'Syntax error in ctypedef statement'
^
------------------------------------------------------------
C:\Documents and Settings\q014gt\Desktop\callback modified\cheese.pyx:7:21: Synt
ax error in ctypedef statement
>>>>>>>>>>>>>>>>>>>>>>
Is this behaviour a bug? I tried cython 0.11.2 and 0.12.1 on WinXP.
A workaround I found is to replace the custom data type by its
definition, as indicated above.
Gregor
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev