3 ms·
Yeah, packing is a pretty well defined to mean adding additional empty bits to keep fields word-aligned.
by vvanders 8y ago
Yeah, 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.