加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

什么与指针相关的东西在Delphi XE8的移动编译器中不起作用?

发布时间:2020-12-15 09:28:49 所属栏目:大数据 来源:网络整理
导读:Embarcadero的docwiki页面 LLVM-based Delphi Compilers列出了Delphi XE8中的几种语言更改.其中一颗子弹说: Use of pointers is not supported by LLVM-based Delphi compilers. 这在实践中究竟意味着什么?以前在Delphi XE7中使用哪些与指针相关的东西,在D
Embarcadero的docwiki页面 LLVM-based Delphi Compilers列出了Delphi XE8中的几种语言更改.其中一颗子弹说:

Use of pointers is not supported by LLVM-based Delphi compilers.

这在实践中究竟意味着什么?以前在Delphi XE7中使用哪些与指针相关的东西,在Delphi XE8中不再有效?我似乎无法在Embarcadero的网站上找到对此的深入解释.据说包含更多信息的页面Migrating Delphi Code to Mobile from Desktop没有提到例如“指针”这个词.

解决方法

Use of pointers is not supported by LLVM-based Delphi compilers.

这必须是文档中的错误.只需看看RTL.它使用指针很厚.

例如,CompareMem怎么样?它的定义如下:

function CompareMem(P1,P2: Pointer; Length: Integer): Boolean;

实现运行如下:

function CompareMem(P1,P2: Pointer; Length: Integer): Boolean;
{$IF defined(POSIX)}
begin
  if Length <= 0 then
    Result := True
  else
    Result := memcmp(P1^,P2^,Length) = 0;
end;
{$ELSEIF defined(PUREPASCAL)}
....
{$ENDIF !PUREPASCAL}

POSIX代码由移动目标使用.

或者看起来像这样的TObject如何:

type
  TObject = class
  public
    constructor Create;
    procedure Free;
    procedure DispoSEOf; {$IFNDEF AUTOREFCOUNT} inline; {$ENDIF}
    class function InitInstance(Instance: Pointer): TObject {$IFDEF AUTOREFCOUNT} unsafe {$ENDIF};
    procedure CleanupInstance;
    function ClassType: TClass; inline;
    class function ClassName: string;
    class function ClassNameIs(const Name: string): Boolean;
    class function ClassParent: TClass;
    class function ClassInfo: Pointer; inline;
    class function InstanceSize: Integer; inline;
    class function InheritsFrom(AClass: TClass): Boolean;
    class function MethodAddress(const Name: _ShortStr): Pointer; overload;
    class function MethodAddress(const Name: string): Pointer; overload;
    class function MethodName(Address: Pointer): string;
    class function QualifiedClassName: string;
    function FieldAddress(const Name: _ShortStr): Pointer; overload;
    function FieldAddress(const Name: string): Pointer; overload;
    function GetInterface(const IID: TGUID; out Obj): Boolean;
    class function GetInterfaceEntry(const IID: TGUID): PInterfaceEntry;
    class function GetInterfaceTable: PInterfaceTable;
    class function UnitName: string;
    class function UnitScope: string;
{$IFDEF AUTOREFCOUNT}
    function __ObjAddRef: Integer; virtual;
    function __ObjRelease: Integer; virtual;
{$ENDIF}
    function Equals(Obj: TObject): Boolean; virtual;
    function GetHashCode: Integer; virtual;
    function ToString: string; virtual;
    function SafeCallException(ExceptObject: TObject;
      ExceptAddr: Pointer): HResult; virtual;
    procedure AfterConstruction; virtual;
    procedure BeforeDestruction; virtual;
    procedure Dispatch(var Message); virtual;
    procedure DefaultHandler(var Message); virtual;
    class function NewInstance: TObject {$IFDEF AUTOREFCOUNT} unsafe {$ENDIF}; virtual;
    procedure FreeInstance; virtual;
{$IFDEF AUTOREFCOUNT}
  protected
{$ENDIF}
    destructor Destroy; virtual;

{$IFDEF CPP_ABI_SUPPORT}
    procedure CPP_ABI_1; virtual;
    procedure CPP_ABI_2; virtual;
    procedure CPP_ABI_3; virtual;
{$ENDIF !CPP_ABI_SUPPORT}

  protected
    function GetDisposed: Boolean; inline;
    procedure CheckDisposed; {$IFNDEF AUTOREFCOUNT} inline; {$ENDIF}

{$IFDEF AUTOREFCOUNT}
  private const
    objDestroyingFlag = Integer($80000000);
    objDisposedFlag = Integer($40000000);
  protected
    [Volatile] FRefCount: Integer;
    class procedure __MarkDestroying(const Obj); static; inline;
    class function __SetDisposed(const Obj): Boolean; static; inline;
  public
    property RefCount: Integer read FRefCount;
{$ENDIF}
    property Disposed: Boolean read GetDisposed;
  end;

很明显,这里的指针用于移动平台.

阅读有关该主题的Embarcadero白皮书:The Delphi Language for Mobile Development.再次介绍了多次使用指针,很明显它们是受支持的.现在,不鼓励使用指针也是如此,如果可以很容易地避免使用指针,那么我们鼓励你这样做.但这与指出编译器不支持指针的情况完全不同.

至少具有讽刺意味的是,Embarcadero正在传播他们自己产品的FUD.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读