[fpc-pascal] All methods vitrual ?
Sven Barth
pascaldragon at googlemail.com
Wed Oct 11 07:57:33 CEST 2023
Adriaan van Os via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am
Mi., 11. Okt. 2023, 06:25:
> Sven Barth via fpc-pascal wrote:
> > Am 10.10.2023 um 11:18 schrieb Adriaan van Os via fpc-pascal:
> >>
> >>>
> >>> - In the released compiler, if you remove all visibility specifiers,
> >>> you can
> >>> get a list by specifying {$M+} on your base object and then list all
> >>> published methods using the RTTI.
> >>
> >> My understanding is that I have to explicitely specify public for
> >> class fields, otherwise the compiler will issue an error.
> >
> > What exactly do you mean here? Do you have an example?
>
> {$mode macpas}
> {$M+}
> program testrtti;
> type
> T = object( TObject)
> i: integer;
> procedure A;
> end;
> procedure T.A;
> begin end;
> begin
> end.
>
> Free Pascal Compiler version 3.0.4 [2018/09/30] for x86_64
> Copyright (c) 1993-2017 by Florian Klaempfl and others
> Target OS: Darwin for x86_64
> Compiling testrtti.pas
> testrtti.pas(6,5) Error: Symbol cannot be published, can be only a class
> testrtti.pas(13) Fatal: There were 1 errors compiling module, stopping
>
Ah, yes, only classes and interfaces can be used for published fields. For
properties anything is allowed.
Regards,
Sven
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20231011/b85812e9/attachment-0001.htm>
More information about the fpc-pascal
mailing list