[fpc-pascal] Typinfo incompatibilities between FPC and Delphi

Sven Barth pascaldragon at googlemail.com
Tue Jun 3 11:08:08 CEST 2014


Am 03.06.2014 10:26 schrieb "Graeme Geldenhuys" <
mailinglists at geldenhuys.co.uk>:
>
> On 2014-05-31 10:57, Vincent Snijders wrote:
> > I think it is possible to write code without $ifdef (valid for Delphi
> > and FPC) if you use the typeinfo unit to extract the information.
> > http://www.freepascal.org/docs-html/rtl/typinfo/
>
> Almost, but not quite. Good news is, it is not nearly as bad as Sven
> makes it out to be.
>

If one uses a helper function like you did then it's indeed not as bad, but
if one doesn't...

> function tiGetTypeInfo(PropInfo: PPropInfo): PTypeInfo;
> begin
> {$IFDEF FPC}
>   Result := PropInfo^.PropType;
> {$ELSE}
>   Result := PropInfo^.PropType^;
> {$ENDIF}
> end;

Out of curiosity: is this helper declared as "inline"? Would get rid of the
call completely in both Delphi and FPC...

>
> I've also introduced an enhanced GetPropInfo() with a signature as
follows:
>
> function tiGetPropInfo(AClass: TClass; PropPath: string; PInstance:
> Pointer): PPropInfo;

Might also profit from a declaration as "inline" :)

Yours,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140603/0d8c0fc6/attachment.html>


More information about the fpc-pascal mailing list