square
is under-parenthesized: it expands textually, so
#define square(x) x*x
...
i=4/square(4);
means
i=4/4*4;
which groups as (4/4) * 4
. To fix, add parentheses:
#define square(x) ((x)*(x))
Still a very iffy #define
as it evaluates x
twice, so square(somefun())
calls the function twice and does not therefore necessarily compute a square but rather the product of the two successive calls, of course;-).