Sign in Join

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

Mailing lists / fpc-pascal / 2012-12

Requirement of {$M+} to add RTTI info

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

luiz americo pereira camara

Some time ago, i was getting an error while trying to use RTTI functions in a class descending directly of TObject

Later i discovered that i needed to descend from TPersistent due to $M+ directive (http://www.freepascal.org/docs-html/prog/progsu44.html), so i did.

Now, i decided to go back and descend directly from TObject. To allow RTTI usage i would put M+ around my own class

I tested again and using RTTI functions (SetOrdProp, GetPropInfo) worked even without declaring {$M+}

So, is it really necessary to put $M+ to use RTTI?

Luiz

Reply by email

Sven Barth
to luiz americo pereira camara

Am 12.12.2012 01:15 schrieb "luiz americo pereira camara" <

Show quoted text 14 lines
: Some time ago, i was getting an error while trying to use RTTI functions in a class descending directly of TObject Later i discovered that i needed to descend from TPersistent due to $M+ directive (http://www.freepascal.org/docs-html/prog/progsu44.html), so i did. Now, i decided to go back and descend directly from TObject. To allow RTTI usage i would put M+ around my own class I tested again and using RTTI functions (SetOrdProp, GetPropInfo) worked even without declaring {$M+}

Can you check whether your unit was really recompiled? Remove the .ppu and .o files for the unit to be on the save side. Also it could be that the switch was declared somewhere before your class and not disabled again with {$M-}

So, is it really necessary to put $M+ to use RTTI?

Yes.

Regards,
Sven

Reply by email

luiz americo pereira camara
to Sven Barth

2012/12/12 Sven Barth :

Show quoted text 20 lines
Am 12.12.2012 01:15 schrieb "luiz americo pereira camara" : > > Some time ago, i was getting an error while trying to use RTTI > functions in a class descending directly of TObject > > Later i discovered that i needed to descend from TPersistent due to > $M+ directive (http://www.freepascal.org/docs-html/prog/progsu44.html), > so i did. > > Now, i decided to go back and descend directly from TObject. To allow > RTTI usage i would put M+ around my own class > > I tested again and using RTTI functions (SetOrdProp, GetPropInfo) > worked even without declaring {$M+} Can you check whether your unit was really recompiled? Remove the .ppu and .o files for the unit to be on the save side.

I already did that

Also it could be that the switch was declared somewhere before your class and not disabled again with {$M-}

Maybe. I also think of a compiler option being passed in Lazarus package but could not find such option

> So, is it really necessary to put $M+ to use RTTI? Yes.

Thanks. I 'll put M+ it anyway

Luiz

Reply by email