According to the specification, In stringization the parameters should not be replaced inside string constants i.e the argument should not be macro expanded.
A sample code demonstrating the problem:
{-#LANGUAGE CPP#-}
#define CHECK_FOR_EQUALITY(exp) if exp then "Equal" else #exp
#define x 3
check :: String
check = CHECK_FOR_EQUALITY(x == 0)
main :: IO ()
main = print check
Running it via cpphs gives this:
#line 1 "cppCode.hs"
{-#LANGUAGE CPP#-}
check :: String
check = if 3 == 0 then "Equal" else "3 == 0"
main :: IO ()
main = print check
But the check definition should be like this:
check = if 3 == 0 then "Equal" else "x == 0"
In fact, I can confirm that gnu's cpp behaves as expected
According to the specification, In stringization the parameters should not be replaced inside string constants i.e the argument should not be macro expanded.
A sample code demonstrating the problem:
Running it via
cpphs
gives this:But the check definition should be like this:
In fact, I can confirm that gnu's cpp behaves as expected