A compiler curiosity I've learned today:
A compiler curiosity I've learned today:
// This works:
{$IF Declared(Test) and (Test>=100)}
{$ENDIF}
// This not:
{$IF Declared(Test)}
{$IF Test>=100} // "E2026 Constant expression expected"
{$ENDIF}
{$ENDIF}
// This works:
{$IF Declared(Test) and (Test>=100)}
{$ENDIF}
// This not:
{$IF Declared(Test)}
{$IF Test>=100} // "E2026 Constant expression expected"
{$ENDIF}
{$ENDIF}
What doesn't work? i.e. do you get an error, is some code included that shouldn't? something else?
ReplyDeleteYes, error "E2026 Constant expression expected" at "$IF Test..."
ReplyDeleteLooks like the compiler is evaluating the $IF despite being in a block that should not.
ReplyDeleteFunny enough I get a W1023 when Test is not declared in the first version facepalm
Stefan Glienke yes, forgot about that. The 1023 warning disappears adding a + in front of 100
ReplyDeleteDid you try $IF (Test>=100) ? I don't have an IDE at hand right now
ReplyDeleteJoaquin Menemene yes, parenthesis or spacing aren't important
ReplyDelete/weird...
ReplyDeleteSounds like a new QP case.
ReplyDeleteLars Fosdal Done: https://quality.embarcadero.com/browse/RSP-17914
ReplyDelete