考虑这个程序:
{$APPTYPE CONSOLE} uses System.SysUtils; procedure Foo; begin end; type TProcedure = procedure; const FooConst: TProcedure = Foo; var FooVar: TProcedure = Foo; P: Pointer; {$TYPEDADDRESS ON} begin P := @Foo; Writeln(Format('%p',[P])); Writeln(Format('%p',[@FooConst])); Writeln(Format('%p',[@FooVar])); Writeln(Format('%p',[@Foo])); Readln; end.
该程序在XE3上编译并运行,并产生以下输出:
00419FB8 00419FB8 00419FB8 00419FB8
在XE4及更高版本上,程序无法编译,并且这两行都有错误消息:
Writeln(Format('%p',[@FooConst])); Writeln(Format('%p',[@FooVar]));
[dcc32 Error] E2250 There is no overloaded version of 'Format' that can be called with these arguments
在XE4,XE5和XE6上,程序在$TYPEDADDRESS关闭时编译.在XE7上,无论$TYPEDADDRESS的设置如何,程序都无法编译.