0

我有以下代码,在 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;

此代码在 Win32 / Win64、Ios32 位下完美运行,但不适用于 IOS64。

使用 Ios64 位,我在该行中遇到访问冲突:

vType:=vPackage.GetTypes

当然,我在编译选项中添加了“发出 RTTI 信息”。

4

1 回答 1

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 ?

于 2016-05-25T00:10:58.617 回答