记录字段的偏移量为常量

Offset of record field as constant

我正在使用如下技术在运行时获取记录字段的偏移量:

procedure DoSomethingWithVar(var AField);
DoSomethingWithVar(TGUID(nil^).D3); // TGUID and D3 for exposition only :-)

这很好用。现在我想将这些偏移量设置为 consts 但无法正常工作:

const
  cMyVarTyped: Pointer = @TGUID(nil^).D3;
  cMyVarUntyped = @TGUID(nil^).D3;
  cMyOffsetTyped: INT_PTR = INT_PTR(@TGUID(nil^).D3);
  cMyOffsetUntyped = INT_PTR(@TGUID(nil^).D3);

它们都产生了 "E2026 Constant expression expected"。有什么想法吗?

FWIW:将声明包装在 {$WRITEABLECONST ON}/{$WRITEABLECONST OFF} 中不会更改错误。

无法让编译器生成包含成员偏移量的常量表达式。