ISO 9899 5.2.4.1 § 1 suggests some limits, but not for the number of expressions inside a conditional block of an if. I think 127 (as in "127 parameters in one function call") is a good limit.
BTW: I've seen this limit imposed on MSVC. This expression, separated by &&, can be interpreted as nested ifs, like:
Code:
if ( condition1 > val1 )
if ( condition2 <= val2 )
if ( ... )
...
And more than 127 nested ifs (on MSVC) will cause a compilation error.
Try to simplify the expression or to shrink the number of comparisons... There are multiple ways to do it and to choose one depends on what you are tring to do. For example: You could notice that the first 4 tests are RANGE tests, and the last 6 are equality tests, so:
Code:
_Bool found = 0;
// range tests.
if ( cond1 > val1 && cond2 <= val2 && cond3 > val3 && cond4 <= val4 )
{
// ISO 9899 suggests a limit of 4095 items in that block!
struct {
int cond, val;
} tests[] = { { cond5, val5 }, { cond6, val6 }, { cond7, val7 }, { cond8, val8 },
{ cond9, val9 }, { cond10, val10 }, { cond11, val11 } };
found = 1;
// "Non" equality tests.
for ( int i = 0; found && i < sizeof tests / sizeof tests[0]; i++ )
if ( tests[i].cond != tests[i].val )
found = 0;
}
if ( found )
{ ... }
This approach has the problem that a copy of the pairs (cond,val) are made to the stack, but avoid the multiple nesting levels.