[fpc-devel] Is that intended: {$define 2} ... {$IFDEF 2}
Martin Frb
lazarus at mfriebe.de
Sun Dec 7 10:05:22 CET 2025
On 06/12/2025 11:10, Michael Van Canneyt via fpc-devel wrote:
>
>
> On Fri, 5 Dec 2025, Martin Frb via fpc-devel wrote:
>
>> $define/$Ifdef don't just take (name) identifiers.
>>
>> They also take numbers, <strike>and expressions. </strike>
>>
>> Well actually, numbers.
>> {$define 2}
>> {$IFDEF 2} .... {$ENDIF}
>>
>
> Seriously ?
>
> The inventive ways by which people try to shoot themselves in the foot
> never
> cease to amaze me...
>
> They do it with lots of enthusiasm, it seems :-)
Ok, so the docs says defines a "name" or "symbol", it does not refer to
"identifier". Which means I guess numbers are in that scope.
And I just realised, the above can be used with macros.
{$macro on}
{$define 0=1}
begin
write(random(123) / 0);
should work ... ;)
More information about the fpc-devel
mailing list