Sign in Join
FPDoc Onlineexperiment

Data alignment

Typed constants and variable alignment

All static data (variables and typed constants) which are greater than a byte are usually aligned on a multiple of two boundary. This alignment applies only to the start address of the variables, and not the alignment of fields within structures or objects for example. For more information on structured alignment, section Memory issues. The alignment is similar across the different target processors.

Data alignment
Data size (bytes) Alignment (small size) Alignment (fast)
1 1 1
2-3 2 2
4-7 2 4
8+ 2 4

The alignment columns indicates the address alignment of the variable, i.e the start address of the variable will be aligned on that boundary. The small size alignment is valid when the code generated should be optimized for size (-Os compiler option) and not speed, otherwise the fast alignment is used to align the data (this is the default).

Structured types alignment

By default all elements in a structure are aligned using natural alignment. unless the $PACKRECORDS directive or packed modifier is used to align the data in another way.

For more information regarding alignment, section Compiler directives

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.