Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-03

Delphi RTTI vs Free Pascal RTTI

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

African Wild Dog

Hello,

I need to write a code compatilble with both free pascal and delphi using the old style RTTI.
What are the diferences between delphi's and free pascal's approach/types?

I took a look at delphi's and fpc's TypInfo unit and it looks like the types/functions are compatible.

Regards

Michael Van Canneyt
to African Wild Dog
African Wild Dog wrote 8 lines
Hello, I need to write a code compatilble with both free pascal and delphi using the old style RTTI. What are the diferences between delphi's and free pascal's approach/types? I took a look at delphi's and fpc's TypInfo unit and it looks like the types/functions are compatible.

They are. There is one dereference on Delphi which is not present in fpc, although in fpc trunk, this additional dereference is there. If you use the standard functions you should not notice this.

Michael.

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
They are. There is one dereference on Delphi which is not present in fpc, although in fpc trunk

Another minor difference is data types. From what I remember (and as can be seen in tiOPF's code. eg: tiRTTI.pas) FPC has a few more data types than Delphi. eg: FPC had tkBool, whereas Delphi didn't. There were also some differences with string types like tkAString, tkUChar and such. Not a big difference though.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp
Karoly Balogh (Charlie/SGR
to Graeme Geldenhuys

Hi,

Graeme Geldenhuys wrote 9 lines
On 2017-03-24 18:55, Michael Van Canneyt wrote: > They are. There is one dereference on Delphi which is not present in fpc, > although in fpc trunk Another minor difference is data types. From what I remember (and as can be seen in tiOPF's code. eg: tiRTTI.pas) FPC has a few more data types than Delphi. eg: FPC had tkBool, whereas Delphi didn't. There were also some differences with string types like tkAString, tkUChar and such. Not a big difference though.

FPC also has tkQWord, among others. Just for the record, here's the FPC version:

http://www.freepascal.org/docs-html/rtl/typinfo/ttypekinds.html

plus a few aliases:

http://www.freepascal.org/docs-html/rtl/typinfo/index-2.html

vs. Delphi version:

http://docwiki.embarcadero.com/Libraries/Seattle/en/System.TTypeKind

Charlie

Sven Barth
to Michael Van Canneyt: They are. There is one dereference on Delphi which is not present in fpc, although in fpc…
"Michael Van Canneyt" wrote 10 lines
On Fri, 24 Mar 2017, African Wild Dog wrote: > Hello, > > I need to write a code compatilble with both free pascal and delphi using > the old style RTTI. > What are the diferences between delphi's and free pascal's

approach/types?

Show quoted text 7 lines
> > I took a look at delphi's and fpc's TypInfo unit and it looks like the > types/functions are compatible. They are. There is one dereference on Delphi which is not present in fpc, although in fpc trunk, this additional dereference is there. If you use

the

standard functions you should not notice this.

The binary data of RTTI added before 3.1.1 now has the double indirection, but the Delphi-compatible "field" names have only a single indirection for backwards compatibility (they are properties to the double indirection fields). RTTI data added in 3.1.1 only has the double indirection. So this difference needs to be kept in mind and will always result in ifdefs for RTTI code that handles both Delphi and FPC.

Regards,
Sven

African Wild Dog
to Sven Barth

2017-03-25 5:40 GMT-03:00 Sven Barth via fpc-pascal <

Show quoted text 37 lines
: Am 24.03.2017 19:55 schrieb "Michael Van Canneyt" < >: > > > > On Fri, 24 Mar 2017, African Wild Dog wrote: > >> Hello, >> >> I need to write a code compatilble with both free pascal and delphi using >> the old style RTTI. >> What are the diferences between delphi's and free pascal's approach/types? >> >> I took a look at delphi's and fpc's TypInfo unit and it looks like the >> types/functions are compatible. > > > They are. There is one dereference on Delphi which is not present in fpc, > although in fpc trunk, this additional dereference is there. If you use the > standard functions you should not notice this. The binary data of RTTI added before 3.1.1 now has the double indirection, but the Delphi-compatible "field" names have only a single indirection for backwards compatibility (they are properties to the double indirection fields). RTTI data added in 3.1.1 only has the double indirection. So this difference needs to be kept in mind and will always result in ifdefs for RTTI code that handles both Delphi and FPC. Regards, Sven

Thanks for the clarifications.

Regards