Delphi 可以对齐字、双字和四字边界上的记录,这取决于{$A}
Delphi 的设置和版本。
如果我必须遵循(坏)代码:
ofSize = $00; <<-- hardcoded will break if I unpack the record.
ofMSB = $01;
ofPtrDigits = $02;
ofSign = $06;
MinSizeBigint: Byte = 10;
type
TBigint = packed record
Size: Byte;
MSB: Byte;
PtrDigits: Pointer;
Sign: TSignValue;
我如何将其转换为:
type
TBigint = record
PtrDigits: Pointer; (*should be `array of cardinal`, but never mind that*)
Size: Byte;
MSB: Byte;
Sign: TSignValue;
ofSize = OffsetOf(TBigInt.Size); <<-- does a function like this exist?
ofMSB = OffsetOf(TBigInt.Size);
ofPtrDigits = OffsetOf(TBigInt.Size);
ofSign = OffsetOf(TBigInt.Size);
是否有一个函数可以使用一些编译器魔法为我填充偏移量?