Re: [Cython] Correct way of defining enums
2011/11/28 Stéfan van der Walt : > > I tried different ways of defining the enum, e.g. > > cdef extern from "ndarraytypes.h": > cpdef enum NPY_SEARCHSIDE: > NPY_SEARCHLEFT = 0 > NPY_SEARCHRIGHT = 1 > This is (near to, see below) the right way, as that NumPy enum do is declared in NumPy headers. > > But that doesn't work either. Any suggestions would be appreciated. > Try "ctypedef enum ..." -- Lisandro Dalcin --- CIMEC (INTEC/CONICET-UNL) Predio CONICET-Santa Fe Colectora RN 168 Km 472, Paraje El Pozo 3000 Santa Fe, Argentina Tel: +54-342-4511594 (ext 1011) Tel/Fax: +54-342-4511169 ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Correct way of defining enums
Hi Licandro On Tue, Nov 29, 2011 at 10:32 AM, Lisandro Dalcin wrote: > This is (near to, see below) the right way, as that NumPy enum do is > declared in NumPy headers. > > Try "ctypedef enum ..." Unfortunately, that doesn't work either :/ (Same error message, no matter which incantation, Cython 0.15.1+) Thanks for the feedback. Stéfan ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Correct way of defining enums
Stéfan van der Walt wrote: Hi Licandro On Tue, Nov 29, 2011 at 10:32 AM, Lisandro Dalcin wrote: Try "ctypedef enum ..." Unfortunately, that doesn't work either :/ Did you try both together? I.e. cdef extern from "ndarraytypes.h": ctypedef enum NPY_SEARCHSIDE: NPY_SEARCHLEFT = 0 NPY_SEARCHRIGHT = 1 -- Greg ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Correct way of defining enums
On Tue, Nov 29, 2011 at 9:08 PM, Greg Ewing wrote: > Did you try both together? I.e. > > cdef extern from "ndarraytypes.h": > ctypedef enum NPY_SEARCHSIDE: > NPY_SEARCHLEFT = 0 > NPY_SEARCHRIGHT = 1 Yeap, no luck :( Does this work on your system? Stéfan ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Correct way of defining enums
The problem was with the definition of PyArray_SearchSorted, namely cdef object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE) The problem was that NPY_SEARCHSIDE wasn't defined as a type, so it was treating that as the argument name (implicitly typed to be object). https://github.com/cython/cython/commit/5ba30c45c7d3478f7b7d0490e720fb0a184c6050 There should probably be at least a mode to give warnings for untyped arguments (and return types) of cdef functions. - Robert 2011/11/29 Stéfan van der Walt : > On Tue, Nov 29, 2011 at 9:08 PM, Greg Ewing > wrote: >> Did you try both together? I.e. >> >> cdef extern from "ndarraytypes.h": >> ctypedef enum NPY_SEARCHSIDE: >> NPY_SEARCHLEFT = 0 >> NPY_SEARCHRIGHT = 1 > > Yeap, no luck :( Does this work on your system? > > Stéfan > ___ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel > ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel