Struct Layout

Back to Alignment & Padding

How the compiler arranges struct fields in memory. Fields are padded to satisfy alignment requirements, and the struct itself may have trailing padding. Field ordering can affect total struct size; some languages allow reordering fields for compactness.

memory-models memory-layout struct padding