Skip to content

IGNORE_DECLARATIONS: Usage? #5

@per42

Description

@per42

I understand IGNORE_DECLARATIONS prunes typedefs from _fake_typedefs.h, which are anyway deliberately incorrect (fake). But that leaves my cython declarations with undeclared data types:

cdef extern from "components/offset_filter.h":
    ctypedef bool Comp_Success
    cdef struct If_Signal_Array:
        size_t count
        uint16_t items[1]

I still need those types to be declared. They can be dummy since the cython generated c code will include the correct headers. By removing the used types in IGNORE_DECLARATIONS, it almost works:

    ...
    ctypedef int size_t
    ctypedef _Bool bool
    ctypedef int uint16_t
    ...

_Bool needs to be replaced by bint, so I added filter for that in parse(). I noticed by accident that size_t is understood by Cython, but that is undocumented so probably best to typedef to int

    ...
    ctypedef int size_t
    ctypedef bint bool
    ctypedef int uint16_t
    ...

An alternative is to manually prepend the generated pxd with:

cdef extern:
    ctypedef bint _Bool

It seems I am missing some step here. What is the intended usage for dealing with standard types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions