[fpc-devel] Is that intended: {$define 2} ... {$IFDEF 2}
Martin Frb
lazarus at mfriebe.de
Fri Dec 5 11:26:37 CET 2025
$define/$Ifdef don't just take (name) identifiers.
They also take numbers, <strike>and expressions. </strike>
Well actually, numbers.
{$define 2}
{$IFDEF 2} .... {$ENDIF}
The below at first looked like expressions too (but as literal text)
But like any directive, it parses until it has the directive (in this
case the first ident "2" and ignores the rest "+1" as comment.
The below is just about the "2":
{$define 2+1}
{$IFDEF 1+2} not compiled {$ENDIF}
{$IFDEF 2+1} foo; {compiled} {$ENDIF}
{$IFDEF 2+ 1} foo; {compiled} {$ENDIF} // note the space
See also
https://forum.lazarus.freepascal.org/index.php/topic,72937.0.html
More information about the fpc-devel
mailing list