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

Am 06/19/2008 08:28 PM schrieb Robert Bradshaw:
On Jun 19, 2008, at 11:23 AM, Johannes Wienke wrote:

Am 06/19/2008 08:09 PM schrieb Robert Bradshaw:
On Jun 19, 2008, at 5:07 AM, Johannes Wienke wrote:
is there a was to use default values for parameters in cdef or cpdef methods? I observed that using them in the pxd files caused a cython
compiler error and using the only in the implementation causes a C
compiler error.

Yes, you need to declare them to have default parameters in .pxd files,
then can use them in .pyx files. For example:

---- pxd ----

cdef foo(x, y=*)

The compiler told me to use '?'. Is that a "bug" in the error message?

No, both are acceptable.

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?


Attachment: PGP.sig
Description: This is a digitally signed message part

_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to