[docs] [issue12880] ctypes: clearly document how structure bit fields are allocated

Vlad Riscutia report at bugs.python.org
Tue Oct 4 20:39:27 CEST 2011


Vlad Riscutia <riscutiavlad at gmail.com> added the comment:

I agree compiler matters for alignment but if you look at PyCField_FromDesc, you will see the layout is pretty much #ifdef MS_WIN32 - #else.

Sorry for generalizing, "all" indeed is not the right word. My point is that we should set expectation correctly - VC++-style on Windows, GCC-style everywhere else and encourage users to access structure members by name, not raw memory. Issues opened for bitfields *usually* are of the form I mentioned - setting raw memory to some bytes then seeing members are not what user expected, even if ctypes algorithm works correctly.

As I said, I will revise the patch and maybe make it more clear that users should look up how bitfield allocation works for their compiler instead of trying to understand this via structure raw memory.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12880>
_______________________________________


More information about the docs mailing list