0

I have the following code , created in a new project with Delphi Berlin (10.1):

Procedure Test;
var
 vRttiContext : TRttiContext;
 vPackages : TArray<TRttiPackage>;
 vTypes : Tarray<TRttiType>;
 vType : TRttiType;
 vPackage : TRttiPackage;
begin
 vRttiContext:=TRttiContext.Create;
 vPackages:=vRttiContext.GetPackages;
 if (vPackages<>nil) then
  for vPackage in vPackages do
   begin
    vTypes:=vPackage.GetTypes;
    case vtype.TypeKind of
     tkClass : ; //DoSomething
    end;
  end;
end;

This code works perfectly under Win32 / Win64, Ios32 bits, but not with IOS64.

With Ios64 bits, I get an access violation in the line :

vType:=vPackage.GetTypes

Of course I added "emit RTTI informations" in the compil options.

Danilo Casa
  • 506
  • 1
  • 9
  • 18
Henry Kerval
  • 392
  • 2
  • 13
  • 1
    I don't see how this code can work since you are not assigning anything to `vType` before accessing `vType TypeKind`. You are missing a second `for` loop. – Remy Lebeau May 24 '16 at 05:28
  • 1
    Your if is needless too – David Heffernan May 24 '16 at 06:36
  • I forget a line when I copied the code for this message. But the fact is that the code will anyway create an access violation on the line "vTypes=vPackage.getTypes" (before using vType). – Henry Kerval May 24 '16 at 10:43

1 Answers1

1

I finally found the issue. The problem was the following code :

  wurRecDouble = packed record
  case byte of
   0 : (Value : Double);
   1 : (Bytes: array [0..7] of Byte);
  end;

Under Ios 64 bits, with RTTI informations active, the line

vTypes:=vPackage.GetTypes;

(See previous code) will generate an A/V (visibly a nil)

If I change the type of Value to Int64 for example the A/V disappears.

Also Delphi doesn't theorically emit RTTI informations for records, so why an A/V with a record ?

Henry Kerval
  • 392
  • 2
  • 13