4 ms·
Hm. I like the approach except for the overloaded meaning of packed. In C, packing means byte-aligned packing, rather than bit-packing. These seem like separ
by loeg 8y ago
Hm. I like the approach except for the overloaded meaning of packed. In C, packing means byte-aligned packing, rather than bit-packing. These seem like separate concepts. (Both are useful! I just think bit-packing should get its own special name.)
- vvanders 8y agoYeah, packing is a pretty well defined to mean adding additional empty bits to keep fields word-aligned.
- iainmerrick 8y agoWord-aligned? No, that's the opposite of packing! I'd say "packing" is ambiguous and could refer to either bit-aligned or byte-aligned data. But if your fields are less than 8 bits wide, I would assume "packing" means bit-packing.
- loeg 8y agoE.g., if your packed struct is { bool a; uint32_t b; }, you probably don't want a totally misaligned-by-one-bit 'b'.
- platinumrad 8y agoIn my experience that's referred to as padding, not packing. A packed struct is what you get when you remove all of the padding. Packing is therefore removing padding, not adding it.
- loeg 8y agoByte-aligned, in C.