### Describe your issue There are a couple of symbols in the NumPy iterator C API that are defined in a way that Cython doesn't like: https://github.com/numpy/numpy/blob/0dbee7ec68f1adcabfb0344c53d65b7f385ae6b5/numpy/_core/include/numpy/ndarraytypes.h#L1067-L1070 If I write a Cython wrapper for this, Cython complains that it returns a function: ``` diff --git a/numpy/__init__.cython-30.pxd b/numpy/__init__.cython-30.pxd index bdadb28d26..74695ccafb 100644 --- a/numpy/__init__.cython-30.pxd +++ b/numpy/__init__.cython-30.pxd @@ -1084,8 +1084,11 @@ # Iterator API added in v1.6 -ctypedef int (*NpyIter_IterNextFunc)(NpyIter* it) noexcept nogil -ctypedef void (*NpyIter_GetMultiIndexFunc)(NpyIter* it, npy_intp* outcoords) noexcept nogil +# +# These don't match the definition in the C API because Cython can't wrap +# function pointers that return functions. +ctypedef int (NpyIter_IterNextFunc)(NpyIter* it) noexcept nogil +ctypedef void (NpyIter_GetMultiIndexFunc)(NpyIter* it, npy_intp* outcoords) noexcept nogil cdef extern from "numpy/arrayobject.h": @@ -1204,8 +1207,11 @@ npy_intp* outstrides) except NPY_FAIL npy_bool NpyIter_IsFirstVisit(NpyIter* it, int iop) nogil # functions for iterating an NpyIter object + # + # These don't match the definition in the C API because Cython can't wrap + # function pointers that return functions. NpyIter_IterNextFunc NpyIter_GetIterNext(NpyIter* it, char** errmsg) except NULL - NpyIter_GetMultiIndexFunc* NpyIter_GetGetMultiIndex(NpyIter* it, + NpyIter_GetMultiIndexFunc NpyIter_GetGetMultiIndex(NpyIter* it, char** errmsg) except NULL char** NpyIter_GetDataPtrArray(NpyIter* it) nogil char** NpyIter_GetInitialDataPtrArray(NpyIter* it) nogil ``` ``` Error compiling Cython file: ------------------------------------------------------------ ... # Iterator API added in v1.6 # # These don't match the definition in the C API because Cython can't wrap # function pointers that return functions. ctypedef int (NpyIter_IterNextFunc)(NpyIter* it) noexcept nogil ^ ------------------------------------------------------------ numpy/__init__.cython-30.pxd:1090:13: Function cannot return a function ``` c.f. https://github.com/numpy/numpy/pull/28453 where a contributor noticed that our wrappers are incorrect and then I found I couldn't write tests for the wrapped functions if I try to work around this error.