20-05-2008, 05:01 PM
There is no situation in which too many parentheses would violate this rule. Both forms:
are perfectly acceptable.
If parentheses are nested too deeply then you may hit a translation limit but if this happens the expression is probably too complicated anyway and should be split.
Rule 12.1 recognises that it would clutter code considerably if every expression were parenthesised. It leaves the matter of what constitutes "too much" clutter up to individual or organisational choice.
Code:
x = a + b;
x = (a + b);
If parentheses are nested too deeply then you may hit a translation limit but if this happens the expression is probably too complicated anyway and should be split.
Rule 12.1 recognises that it would clutter code considerably if every expression were parenthesised. It leaves the matter of what constitutes "too much" clutter up to individual or organisational choice.
Posted by and on behalf of the MISRA C Working Group