基于 LLVM 的 Delphi 编译器不支持使用指针。
那必须是文档中的错误。看看 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 白皮书:用于移动开发的 Delphi 语言。它再次涵盖了在多个场合使用指针,很明显它们是受支持的。现在,不鼓励使用指针也是事实,如果可以很容易地避免使用指针,那么我们鼓励您这样做。但这与声明编译器不支持指针完全不同。
Embarcadero 正在传播他们自己产品的 FUD,这似乎至少有点讽刺意味。