Rule 12.1 - are extra parentheses not compliant? - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA-C: 2004 rules (https://forum.misra.org.uk/forumdisplay.php?fid=17) +---- Forum: 6.12 Expressions (https://forum.misra.org.uk/forumdisplay.php?fid=39) +---- Thread: Rule 12.1 - are extra parentheses not compliant? (/showthread.php?tid=512) |
Rule 12.1 - are extra parentheses not compliant? - pkruk - 13-05-2008 Quote:However, do not add too many parentheses so as to clutter the code and make it unreadable.Does it means that the "not required" parentheses below are a violation of this rule? If not, is there a case where too many parentheses is a violation to this rule? Code: x = a + b; /* acceptable */ Re: Rule 12.1 - are extra parentheses not compliant? - misra-c - 20-05-2008 There is no situation in which too many parentheses would violate this rule. Both forms: Code: 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. |