Purpose
I am writing a network program in C (specifically gnu89
) and I would like to simplify things by reinterpreting a certain
Assuming that you are asking whether the struct members will retain the order specified in their definition, the answer is yes. The Standard requires that successive members have increasing addresses:
Section §6.7.2.1p13:
Within a structure object, the non-bit-field members and the units in which bit-fields reside have addresses that increase in the order in which they are declared.
and the documentation for the packed attribute clearly states that only padding/alignment is affected:
The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute.