[Cython] Defaults in cdef or cpdef methods

Robert Bradshaw robertwb at math.washington.edu
Thu Jun 19 21:00:59 CEST 2008


On Jun 19, 2008, at 11:43 AM, Johannes Wienke wrote:

...

>>>
>>> Ok, then it didn't solve my problem. Jus tried that out and as  
>>> both *
>>> and ? are possible, I got the same error message:
>>>
>>> build/temp.linux-x86_64-2.4/pyrex/plugins.c: In function 'PyObject*
>>> __pyx_pf_4ship_7icewing_7plugins_14PluginInstance_init(PyObject*,
>>> PyObject*, PyObject*)':
>>> build/temp.linux-x86_64-2.4/pyrex/plugins.c:1228: error: invalid  
>>> lvalue
>>> in unary '&'
>>> error: command 'x86_64-pc-linux-gnu-g++' failed with exit status 1
>>>
>>> My pxd file looks like that:
>>>
>>> cpdef class PluginInstance(Plugin):
>>>     #....
>>>     cpdef getName(self)
>>>     cpdef init(self, args=*)
>>>     cpdef process(self, d)
>>>
>>> And the method body:
>>>
>>>     cpdef init(self, args = ""):
>>>         argList = helpers.splitArgs(args)
>>>         # ...
>>>
>>> The line in the C code that gcc does complain about is:
>>>
>>> __pyx_1 = (__pyx_skip_dispatch = 1, ((struct
>>> __pyx_vtabstruct_4ship_7icewing_7plugins_PluginInstance *)((struct
>>> __pyx_obj_4ship_7icewing_7plugins_PluginInstance
>>> *)__pyx_v_self)->__pyx_vtab)->init(((struct
>>> __pyx_obj_4ship_7icewing_7plugins_PluginInstance *)__pyx_v_self),  
>>> ((void
>>> *)&((struct
>>> __pyx_opt_args_4ship_7icewing_7plugins_14PluginInstance_init) 
>>> {1,__pyx_v_args}))));
>>>
>>> if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0];  
>>> __pyx_lineno = 93;
>>> goto __pyx_L1;}
>>>
>>> Is there something I am doing wrong?
>>
>> Hmm... what version of gcc are you using?
>
> 4.1.2 on amd64

Apparently this is valid C, but not valid C++. http://trac.cython.org/ 
cython_trac/ticket/21

C++ gurus, any ideas?

- Robert


-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://codespeak.net/pipermail/cython-dev/attachments/20080619/117b9e8b/attachment.pgp 


More information about the Cython-dev mailing list