|
#define min(a,b) ((a)<(b)?(a):(b)) |
This macro and those that follow will lead to unexpected behavior if certain expressions are passed into it. For example,
int x = 0, y = 1;
printf("Min is: %d", min(++x, ++y));
Will print 2 instead of 1 since the expansion gives the expression ((++x)<(++y)?(++x):(++y)). Is there a reason this shouldn't be a function?