Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TVarData Differences between x86 and x64 Delphi

Tags:

delphi

dehl

I couldn't find any explanation about TVarData in x64. There is a page in Help but it seems TVarData in x64 and TVarData in x86 are different. Actually I'm trying to compile DEHL for x64 target. But it says "Invalid typecast" on this line:(Source is TVarData)

Big := TBigCardinalVarData(Source).BigCardinalPtr^;

And TBigCardinalVarData is here:

TBigCardinalVarData = packed record
  VType: TVarType;
  Reserved1, Reserved2, Reserved3: Word;
  BigCardinalPtr: PBigCardinal;
  Reserved4: LongWord;
end;

It compiles in x86, but it refuses to compile in x64. I think the problem is in Word and LongWord variables. But I couldn't figure it yet.

like image 575
oruchreis Avatar asked Oct 15 '11 17:10

oruchreis


1 Answers

The problem is the packed record declaration, the Packed Record Type Becomes Record Type in X64, so you must remove the "packed" from "packed record" in the declaration and instead use the ALIGN Directive.

{$ALIGN 8}
TBigCardinalVarData = record
  VType: TVarType;
  Reserved1, Reserved2, Reserved3: Word;
  BigCardinalPtr: PBigCardinal;
  Reserved4: LongWord;
end;

for more info read these entries

  • Delphi Compiler Changes for XE2
  • Converting 32-bit Delphi Applications to 64-bit Windows
like image 51
RRUZ Avatar answered Sep 27 '22 22:09

RRUZ