Type Switch Syntax {$A+}, {$A-}, {$A1}, {$A2}, {$A4}, or {$A8} {$ALIGN ON}, {$ALIGN OFF}, {$ALIGN 1}, {$ALIGN 2}, {$ALIGN 4}, or {$ALIGN 8} Default {$A8} {$ALIGN 8} Scope Local ResThe $A directive controls alignment of fields in Delphi record types and class structures. 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 double-word 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 quad word boundaries. Record type field alignment is described in the Delphi Language Guide. See 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.
Syntax {$A+}, {$A-}, {$A1}, {$A2}, {$A4}, or {$A8}
{$ALIGN ON}, {$ALIGN OFF}, {$ALIGN 1}, {$ALIGN 2}, {$ALIGN 4}, or {$ALIGN 8}
Default {$A8}
{$ALIGN 8}
Scope Local
ResThe $A directive controls alignment of fields in Delphi record types and class structures.
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 double-word 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 quad word boundaries.
Record type field alignment is described in the Delphi Language Guide. See 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.
比如你声明了一个boolean,byte,intger,word,就是四个字节(intger最大),
如果没有intger就是两个字节(word最大).
to outer2000:
能否写个具体例子,如何定义?这种方法没用过,惭愧.
谢谢.
type
TByteAlign = packed record
A: Byte;
B: Word;
C: Integer;
end;只要在 record 前加 packed 即可.SizeOf(TByteAlign) = 7;
若去掉 packed, 则 SizeOf(TByteAlign) = 8;