4 ms·
Yeah, but keeping this stuff in mind can really help when you're ordering members in a struct/class.
by lallysingh 17y ago
Yeah, but keeping this stuff in mind can really help when you're ordering members in a struct/class.
- palish 17y agoThat is a very good point. Every C/C++ developer should be familiar with #pragma pack (Visual Studio... not sure what the GCC equivalent is).
- JoachimSchipper 17y agogcc has __attribute__((packed)), but we may be talking about different things - that's mostly used for on-the-wire protocols. For most structs, laying out the members from large to small works fine, and avoids superfluous shifting on every read and write.