Replies: 3 comments
-
Let me flesh that out .. the client has to first define an ordinary integer in a structure containing the bit fields, and give it a dummy name. Then a bit field specification can be given for that field, giving the offset and length. I think the client programmer can write these routines anyhow. So maybe it isn't necessary in Ctypes after all. |
Beta Was this translation helpful? Give feedback.
-
Right: there's currently no support for bitfields (#226), but I think it'd be useful to have. |
Beta Was this translation helpful? Give feedback.
-
Yeah, its tricky for the programmer. I have fields like
where it's clear from context the 4 fields, adding to 32, are intended to be consecutive in a 32 bit word. But this is equivalent:
but doesn't present the same intent to my human brain. I don't see how the layout can be guessed by a machine. |
Beta Was this translation helpful? Give feedback.
-
I may have missed it but bit fields aren't handled, right?
So bitfields are actually easy to handle with
where the two ints are the left shift count and the mask length and the
base is the underlying integer. This put the onus on the programmer
to calculate the offset for their platform.
Beta Was this translation helpful? Give feedback.
All reactions