delphi 的结构体对齐关键字

本文详细介绍了Delphi编译器中$A指令的使用方法及其对记录类型字段对齐的影响。该指令控制编译器为对齐字段而引入填充的最大对齐方式。文章还解释了不同状态(如{$A1}

Align fields (Delphi)

 

Go Up to Delphi 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 Delphi Language Guide at Internal Data Formats (Delphi)#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 OS X applications, stack alignment must be on 16-byte boundaries. For details, see Eli Boling's blog at http://blogs.embarcadero.com/eboling/2009/05/20/5607

转载于:https://www.cnblogs.com/h2zZhou/p/6774624.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值