2

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

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
bman
  • 5,016
  • 4
  • 36
  • 69

1 Answers1

12

"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).

skamradt
  • 15,366
  • 2
  • 36
  • 53
utku_karatas
  • 6,163
  • 4
  • 40
  • 52
  • 3
    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) – Daniel Rikowski Sep 22 '09 at 08:32