March 2000
Intermediate to advanced
576 pages
18h 13m
English
$Align Compiler Directive
{$A+} // default
{$Align On} // default
{$A-}
{$Align Off}Local
When
enabled, the $A or
$Align
directive
aligns class, object, and record fields. When disabled, all
structured types are packed. Alignment helps a program run faster,
but at the expense of additional memory.
Use the $Align directive at the beginning of a
file to affect all declarations in that file. For individual
declarations, it’s better to use the packed
modifier.
type
{$Align On}
TPadded = record
A: Byte;
B: Integer; // Delphi inserts padding between A and B to align B
end;
TPacked = packed record
A: Byte;
B: Integer; // no padding because the record is packed
end;
{$Align Off}
TUnaligned = record
A: Byte;
B: Integer; // no padding because the record is not aligned
end;| Packed Keyword |
Read now
Unlock full access