20 Nov 2020 20 Nov '20
Thank you for this patch! I can't help land it, but it looks sane to me.
I fear you have discovered a fundamental truth about ctypes though -- it tries to mimic what C compilers do and this inevitably leads to many discrepancies. E.g. if a C structure you're trying to use is wrapped in an #ifdef, one has to then try to mimic that ifdef in Python, which may be impossible or very fragile.
If you're encountering such issues, you might save yourself future pain and bugs by switching to an alternative approach (cython, CFFI, struct module -- it depends on what problem you're trying to solve).
Will hold thumbs that you find someone to review and merge the patch!
Yours sincerely, Simon Cross