- I have two 2-D arrays close and open
-
I have defined 2 macros min(a,b) and max(a,b) as
#define min(a,b) (a<b?a:b) #define max(a,b) (a>b?a:b)
And I’m using an expression in my code which is as follows:
max( close[i-1][ii], open[i-1][ii] ) < max( close[i-2][ii], open[i-2][ii] )
However, this returns the following warning:
warning: comparisons like X<=Y<=Z do not have their mathematical meaning
I believe the preprocessor is doing something of the sort of
a<b<c
replacement which might explain the warning from the compiler. How do I resolve this?
Macros just replace text so you need to parenthesize everything.
If you are using C++, there are much better alternatives though. Inline functions have the same performance as macros while being much better behaved.