views:

408

answers:

1

I'm converting GraphicEx project to Delphi 2009.

I have trouble in converting following procedure in unit Scanf_c.pas. Here is the problem:

  With TscRec(FType) do begin

FType is an integer and TscRec is defined:

  TscRec = packed record  // Has size of an integer
      Case byte of
        0: ( Typ : byte; Size : char; Flags : word;);
        1: ( SizeType : word; iFlags : smallInt;);
      end;

It seems that this code is working fine in delphi 2007, but I have problem in compiling it in Delphi 2009. The compiler error is "Invalid Typecase". The problem is cause from typecasting FType which is integer to TScRec which is a record.

Does somebodye here have same problem with Delphi 2009 and have a solution.

Thx

+10  A: 

"char" is now a 2 byte data type. What happens if you change the declaration to "ansichar"? (That is the equivalent of "char" in Delphi <= 2007).

utku_karatas
+1 - it works with AnsiChar
Ralph Rickenbach
Remove the "wild guess", because that's in fact the answer. :) With Char the first branch would be 5 bytes long, and that would be no longer the size of an integer (4)
DR