1.2.9 $CODEALIGN : Set the code alignment

This switch sets the code alignment. It takes an argument which is the alignment in bytes.

{$CODEALIGN 8}

There are some more arguments which can be specified, to tune the behaviour even more. The general form is

{$CODEALIGN PARAM=VALUE}

Where PARAM is the parameter to tune, and VAR value is a numerical value specifying an alignment. PARAM can be one of the following strings:

PROC
Set the alignment for procedure entry points.
JUMP
Set the alignment for jump destination locations.
LOOP
Set alignment for loops (for, while, repeat).
CONSTMIN
Minimum alignment for constants (both typed and untyped).
CONSTMAX
Maximum alignment for constants (both typed and untyped).
VARMIN
Minimum alignment for static and global variables.
VARMAX
Maximum alignment for static and global variables.
LOCALMIN
Minimum alignment for local variables.
LOCALMAX
Maximum alignment for local variables.
RECORDMIN
Minimum alignment for record fields.
RECORDMAX
Maximum alignment for record fields.

By default the size of a data structure determines the alignment:

With the above switches the minimum required alignment and a maximum used alignment can be specified. The maximum allowed alignment is only meaningful if it is smaller than the natural size. i.e. setting the maximum alignment (e.g. VARMAX) to 4, the alignment is forced to be at most 4 bytes: The Int64 will then also be aligned at 4 bytes. The SmallInt will still be aligned at 2 bytes.

These values can also be specified on the command line as

-OaPARAM=VALUE