About the author
Given there's a single type declaration,
THDItem
and that I wanted to see the field offsets as well as calculate the total size of the record, using Delphi's RTTI, I can do so with:
var rtype: TRTTIType; fields: TArray<TRTTIField>; LFieldName: string; P: Pointer; LTotalSize: Integer; LHDItem: THDItem; begin rtype := TRTTIContext.Create.GetType(TypeInfo(THDItem)); P := @LHDItem; fields := rtype.GetFields; for i := 0 to High(fields) do begin LFieldName := fields[i].Name; if LFieldName.StartsWith('placeholder', True) then Continue; WriteLn(Format('%-20s: %-10s :: %-30s, Addr: %.8x', [ LFieldName, fields[i].FieldType.ToString, fields[i].GetValue(P).ToString, fields[i].Offset])); LTotalSize := LTotalSize + fields[i].FieldType.TypeSize; end; WriteLn('Size: ', LTotalSize); end;
Learn why the map is cool in Go!
A method to design records so that they're allocated on a specific byte boundary, such as 16 bytes, 512 bytes, 4096 bytes, etc.
Learn the command line used to compile System.pas in Delphi
How to free more space on your home drive by redirecting the location for SDKs in RAD Studio