Rule 14.3 and null macros - 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.14 Control Flow (https://forum.misra.org.uk/forumdisplay.php?fid=46) +---- Thread: Rule 14.3 and null macros (/showthread.php?tid=846) |
Rule 14.3 and null macros - JohnC - 14-09-2011 If a function is sometimes to be included and sometimes omitted, the classic solution is to define it like this: Code: #if FnIsWanted As already noted, this falls foul of rule 14.3, though primarily it is a breach of rule 19.4 (what a macro can be defined as). I can get the the effect I want on my compiler without apparently breaching MISRA rules by using the following alternative: Code: #if FnIsWanted However, the body of this do-while is a null (compound) statement, so has my compiler missed a violation? Re: Rule 14.3 and null macros - misra-c - 21-09-2011 MISRA C uses the term "null statement" in the same way as the standard, namely a statement consisting of nothing but a semicolon character. The body of the while loop is an empty compound statement but it's not syntactically a null statement. Therefore the checker is correct not to report a violation of Rule 14.3. |