Hi,
On Thu, 6 Apr 2023 at 13:10, mt <
firstl...@gmail.com> wrote:
> Because the partial support for real-world C header files of pycparser makes generating C bindings autonomously impossible.
You know that you cannot drop an existing, unmodified C header into
ffi.cdef() and be done with it, right? Of course you can't if the
headers use non-C99 extensions of the language, but it's also true if
they don't.
There are some 3rd-party projects that use CFFI by doing various kinds
of preprocessing on the real C header until it is suitable for their
use case to put in a cdef(). For the case you have in mind, maybe you
could parse the headers using libclang, extract the parts that make
sense, and emit sanitized C code again, which you can put in a cdef().
Within the scope of one project, it's possible to do this. But it's
not included with CFFI because the details are really dependent on the
project; I believe it would be hard to find a one-size-fits-all
solution. I prefer to keep this part into the hands of 3rd-party
projects, with maintainers closer to their particular problem than I
am.
Armin Rigo