Align fields (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Object Pascal Compiler Directives (List) Index

Type

Switch

Syntax

{$A+}, {$A-}, {$A1}, {$A2}, {$A4}, {$A8} or {$A16} {$ALIGN ON}, {$ALIGN OFF}, {$ALIGN 1}, {$ALIGN 2}, {$ALIGN 4}, {$ALIGN 8} or {$ALIGN 16}

Default

{$A8} {$ALIGN 8}

Scope

Local



Remarks

The $A directive controls the maximum alignment used by the compiler when introducing padding to align a field.

In the {$A1} or {$A-} state, fields are never aligned. All record and class structures are packed.

In the {$A2} state, fields in record types that are declared without the packed modifier and fields in class structures are aligned on word boundaries.

In the {$A4} state, fields in record types that are declared without the packed modifier and fields in class structures are aligned on doubleword boundaries.

In the {$A8} or {$A+} state, fields in record types that are declared without the packed modifier and fields in class structures are aligned on quadword boundaries.

In the {$A16} state, fields in record types that are declared without the packed modifier and fields in class structures are aligned on double quadword boundaries.

Record type field alignment is described in the Object Pascal Language Guide at Record Types.

Regardless of the state of the $A directive, variables and typed constants are always aligned for optimal access. In the {$A8} state, execution will be faster.

For Mac OS X applications, stack alignment must be on 16-byte boundaries.

See Also