[fpc-pascal] All methods vitrual ?

Adriaan van Os adriaan at adriaan.biz
Fri Oct 13 10:57:46 CEST 2023


Martin Frb via fpc-pascal wrote:
> On 11/10/2023 16:46, Adriaan van Os via fpc-pascal wrote:
>> I don't see any use in allowing or disallowing something. And with the 
>> current design, it is, as I said, impossible, without macros, to 
>> compile the same code with {$M+} and {$M-}.
> 
> Use $IfOpt instead of macros?
> 
> {$IfOpt M+} published {$Else} public {$EndIf}

I have a generic include file that has

{$ifc not defined HaveTypeInfo}
{$M-}
{$definec visible public}
{$elsec}
{$ifc HaveTypeInfo}
{$M+}
{$definec visible published}
{$elsec}
{$M-}
{$definec visible public}
{$endc}
{$endc}

and now I can use "visible" as a new visibility specifier, which is more elegant and easy-to-read 
(and less typing) than polluting the code with lots of

	{$IfOpt M+} published {$Else} public {$EndIf}

Regards,

Adriaan van Os



More information about the fpc-pascal mailing list