[fpc-pascal] Requirement of {$M+} to add RTTI info

Sven Barth pascaldragon at googlemail.com
Wed Dec 12 09:44:20 CET 2012


Am 12.12.2012 01:15 schrieb "luiz americo pereira camara" <luizmed at oi.com.br
>:
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121212/9c545ebc/attachment.html>


More information about the fpc-pascal mailing list