Content deleted Content added
Peter Flass (talk | contribs) →Data structure padding: PL/I |
Guy Harris (talk | contribs) →Data structure padding: Data structure refers to more than what C calls "structs" and what some other languages calls "records"; what's meant here is a record. |
||
Line 70:
Although the [[compiler]] (or [[interpreter (computing)|interpreter]]) normally allocates individual data items on aligned boundaries, data structures often have members with different alignment requirements. To maintain proper alignment the translator normally inserts additional unnamed data members so that each member is properly aligned. In addition, the data structure as a whole may be padded with a final unnamed member. This allows each member of an [[array of structures]] to be properly aligned.
Padding is only inserted when a [[
Although C and C++ do not allow the compiler to reorder structure members to save space, other languages might. It is also possible to tell most C and C++ compilers to "pack" the members of a structure to a certain level of alignment, e.g. "pack(2)" means align data members larger than a byte to a two-byte boundary so that any padding members are at most one byte long. Likewise, in [[PL/I]] a structure may be declared <code>UNALIGNED</code> to eliminate all padding except around bit strings.
|