E2026 or W1023 – take your pick (:
Posted by jpluimers on 2018/08/08
[WayBack] A compiler curiosity I’ve learned today … – David Berneda – Google+: depending on if TEST is defined or not, you get E1026 or W1023.
// This works:
{$IF Declared(Test) and (Test>=100)}
{$ENDIF}
// This not:
{$IF Declared(Test)}
{$IF Test>=100} // "E2026 Constant expression expected"
{$ENDIF}
{$ENDIF}
The W1023 can be alleviated by replacing 100
with +100
.
Note that both errors have been documented since at least Delphi 2007:
- [WayBack] W1023: Comparing signed and unsigned types – widened both operands
- [WayBack] Constant expression expected (E2026)
–jeroen
Source: A compiler curiosity I’ve learned today: // This works: {$IF Declared(Test) …
cesarliws said
Different from the working declaration, the erroneous one is lacking the parentheses, I’m wondering if it can work.
{$IF (Test>=100)}
PS: I do not have Delphi here at my work to test it right now.
jpluimers said
Interesting thought. Hopefully I have some time next week to check it out.