I would like to do some very basic boolean operations within compiler directives. $IF does not seem to work reliably. See below:
C:\fpc\test>fpc directive_test -Sm Free Pascal Compiler version 1.0.10 [2003/06/27] for i386 [...] User defined: ========================= User defined: $define x:=17 User defined: !!! (x=5) = TRUE even though i set x:=17 User defined: . (x>50) = false (good, x=17) User defined: !!! (x<50) = FALSE even though i set x:=17 User defined: !!! ($if 1 AND 0) = TRUE User defined: ========================= User defined: $define zero:=0 User defined: !!! ($if zero) = TRUE User defined: !!! ($if 0) = TRUE User defined: and now the exact same test again... User defined: . ($if 0) = false User defined: ========================= User defined: $define apples User defined: !!! ($ifdef oranges or apples) = FALSE :-( User defined: ========================= Linking directive_test.exe 68 Lines compiled, 1.2 sec I know boolean operators are not supported for $ifdef, but it would sure be nice. The most baffling part is where {$IF 0} = true and then the same {$IF 0} = false. It seems to be related to the test done just prior to it -- If I follow the 'zero' test with the {$IF 0} test, the latter doesn't work. Here is the source: begin {$info =========================} {$define x:=17} {$info $define x:=17} {$if x=5} {$info !!! (x=5) = TRUE even though i set x:=17} {$else} {$info . (x=5) = false (good, x=17)} {$endif} {$if x>50} {$info !!! (x>50) = TRUE even though i set x:=17} {$else} {$info . (x>50) = false (good, x=17)} {$endif} {$if x<50} {$info . (x<50) = true (good, x=17)} {$else} {$info !!! (x<50) = FALSE even though i set x:=17} {$endif} {$if 1 AND 0} {$info !!! ($if 1 AND 0) = TRUE} {$else} {$info . ($if 1 AND 0) = false} {$endif} {$info =========================} {$define zero:=0} {$info $define zero:=0} {$if zero} {$info !!! ($if zero) = TRUE} {$else} {$info . zero returned false} {$endif} {$if 0} {$info !!! ($if 0) = TRUE} {$else} {$info . ($if 0) = false} {$endif} {$info and now the exact same test again...} {$if 0} {$info !!! ($if 0) = TRUE} {$else} {$info . ($if 0) = false} {$endif} {$info =========================} {$define apples} {$info $define apples} {$ifdef oranges or apples} {$info . ($ifdef oranges or apples) = true} {$else} {$info !!! ($ifdef oranges or apples) = FALSE :-( } {$endif} {$info =========================} end. _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal