I'm writing a C extension for Python and need to pass the size of a C type to the compilation. So I'll want to do
extra_compile_args = ['-DSIZEOF_MYTYPE=32']
in my setup.py. My question is: how can I get the size? (32 here)
If my target were pure C and I use autoconf, then I could use AC_CHECK_SIZEOF, if writing a Ruby extension there is check_sizeof in the mkmf module, is there some similar facility (presumably, like autoconf and Ruby's mkmf, by making a test-compile which calls C's sizeof and prints the result to stdout, and capturing that) in Python? Or do I need to roll my own?
struct.calcsizeorctypes.sizeofwould probably be the most appropriate built-in tools for the job, but they can't parse your C headers to read your type definitions or anything like that, so you'd have to repeat the type definitions in a formatstructorctypesunderstands.sizeofworks just fine -- many thanks! If you would like to convert that comment to an answer, I'll make as solved