[fpc-pascal] All methods vitrual ?

Adriaan van Os adriaan at adriaan.biz
Wed Oct 11 06:25:24 CEST 2023


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

Regards,

Adriaan van Os



More information about the fpc-pascal mailing list