|
|
|
|
|
by m3koval
3977 days ago
|
|
The bitfield example is misleading. Section 6.7.2.1/10 of the C99 standard says: "The order of allocation of bit-fields within a unit (high-order to low-order or low-order to high-order) is implementation-defined" There is no guarantee on the order of the bits inside a bitfield. The compiler may also introduce padding, e.g. for alignment purposes. This makes bitfields unusable for unpacking binary data. Unfortunately, you're stuck with shifting and masking to replicate the same effect. |
|