// *** before: ***
// there was one target, 32-bit Windows. Integer and Pointer were both
// four bytes, so keeping a pointer in an Integer always worked
var
P: Pointer;
I: Integer;
begin
I := Integer(P);
Writeln(SizeOf(Pointer)); // always 4
end;
// *** in version XE2: ***
// the same source builds for Win32 and for Win64
var
P: Pointer;
N: NativeInt; // as wide as a pointer on the current target
begin
N := NativeInt(P); // this is the cast that survives both
Writeln(SizeOf(Pointer)); // 4 on Win32, 8 on Win64
Writeln(SizeOf(Integer)); // 4 on both - Integer(P) now truncates
{$IFDEF CPUX64}
Writeln('64-bit build');
{$ENDIF}
{$IFDEF CPUX86}
Writeln('32-bit build');
{$ENDIF}
end;
// what breaks in old code: assembler blocks, pointer arithmetic through
// Integer, and any record laid out for an external API by hand