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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to