Struct Reordering by compiler [duplicate]
问题 This question already has answers here : Why can't C compilers rearrange struct members to eliminate alignment padding? [duplicate] (11 answers) Closed 3 years ago . Suppose I have a struct like this: struct MyStruct { uint8_t var0; uint32_t var1; uint8_t var2; uint8_t var3; uint8_t var4; }; This is possibly going to waste a bunch (well not a ton) of space. This is because of necessary alignment of the uint32_t variable. In actuality (after aligning the structure so that it can actually use