[Cython] Correct way of defining enums

Robert Bradshaw robertwb at math.washington.edu
Wed Nov 30 08:15:02 CET 2011


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 <stefan at sun.ac.za>:
> On Tue, Nov 29, 2011 at 9:08 PM, Greg Ewing <greg.ewing at canterbury.ac.nz> 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 at python.org
> http://mail.python.org/mailman/listinfo/cython-devel
>


More information about the cython-devel mailing list