What about Macros for 14.3? - 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: What about Macros for 14.3? (/showthread.php?tid=19) |
What about Macros for 14.3? - gs - 20-12-2004 Expanding upon the example in the MISRA 2004 Standard for 14.3: #define WHATABOUTTHIS /* Um */ ; #define ORTHIS #define ANDTHISTOO /* Well, I, uh... */ void f() { ; /* OK */ /* Not OK */ ; ;/* Not OK */ WHATABOUTTHIS ORTHIS; ANDTHISTOO; } Which of the lines with macros, if any, violate the Rule? - Gavin McCall - 09-09-2005 Code: #define M1 ; This macro breaks rule 19.4. Macro expanding to Null statement is not allowed. Code: #define M2 This macro expands to no body, and is therefore not prohibited by 19.4. A comment in a macro definition is removed by the pre-processor. Rule 14.3 applied before Pre-processing. Treatment of M2 and M3 is identical. Code: M1 Since definition of M1 macro was invalid, its use is already a violation. Code: M2; After pre-processing, these are both Null statements. Before pre-processing, there are characters before the Null statement. This is not allowed by 14.3. - misra-c - 29-08-2006 Quote: Re-posted under offical user name only. |