[fpc-devel] Questions on RTTI

Martin Frb lazarus at mfriebe.de
Fri Oct 23 10:48:00 CEST 2026


Can someone check the below statements for correctness please?


---------------------------------------------------


- A  class itself has always some RTTI of its own. (but that does not 
describe all the fields/members)

-  other types may also have RTTI (even if they are outside a published 
section, or even outside a class)

- fields/members can be found via RTTI  if they are published. That is 
the field/member can be looked up by name within the RTTI of the class.

    (and that returns the RTTI for the field's type / and the location 
or getter/setter of the field)


So for the "published" case the DW_TAG_Member needs to have the flag 
(indicating the presence of RTTI)

(actually indicating that the containing type has type info for that 
field, and its type)


I'll have to double check the below with the fpc team, to make sure I 
got the nitty gritty parts correct.


RTTI may also be available for a type. Then the type would want to have 
that flag, but that would not relate to the published concept.

Some types have always RTTI for the type. Such types could be declared 
scoped inside a class. But that would not mean they are published.


Afaik (and as I said, I am double checking that)

type

    TFoo = class

    public type

        TMyEnum =(mon,tue,wed,thu,fri);

   public

        FMyAnonEnumVal = (Jan, Feb, Mar, Apr);

    published

        Value: integer;

    end;


TMyEnum has rtti for the type. But can't be looked up by name. (afaik 
enums always produce RTTI, becaues they can be printed (with writeln) 
using the name, rather than the stored ordinal val)

The same for FMyAnonEnumVal.


But the published "Value" can also be found by looking up the name 
"Value" starting from the class.


That could be distinguishable by having the flag on the type (in the 2 
public cases), and on the member for the published case.




More information about the fpc-devel mailing list