Delphi can align records on word, double-word and quad-word bouderies, depending on the {$A}
setting and the version of Delphi.
If I have to following (bad) code:
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;
How do I transform it into this:
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);
Is there a function that will fill in the offsets for me using some compiler magic?