Skip to content

[BUG] C typedef function pointers are (sometimes) not parsed #5779

@videlec

Description

@videlec

Describe the bug

Cython seems to be confused by typedef function pointers when the return type is a ctypedef.

Code to reproduce the behaviour:

A declaration such as

cdef extern from "my_header.h":
    ctypedef enum truth_t:
        T_TRUE
        T_FALSE

    ctypedef truth_t ((*boolean_function)(int))

ends up with

$  cython test.pyx
Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "my_header.h":
    ctypedef enum truth_t:
        T_TRUE
        T_FALSE

    ctypedef truth_t ((*boolean_function)(int))
                       ^
------------------------------------------------------------

test.pyx:6:23: Expected an identifier, found '*'

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "my_header.h":
    ctypedef enum truth_t:
        T_TRUE
        T_FALSE

    ctypedef truth_t ((*boolean_function)(int))
                        ^
------------------------------------------------------------

test.pyx:6:24: Declarator should be empty

Expected behaviour

No response

OS

linux

Python version

3.10.12

Cython version

3.0.2

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions