MISRA Discussion Forums
Rule 19.14 - multiple defines - 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.19 Preprocessing Directives (https://forum.misra.org.uk/forumdisplay.php?fid=43)
+---- Thread: Rule 19.14 - multiple defines (/showthread.php?tid=847)



Rule 19.14 - multiple defines - JohnC - 15-09-2011

Is this permissible under rule 19.14?

Code:
#define X ((defined(Y)) || (defined(Z)))
#if X
...
#endif

JohnC.


Re: Rule 19.14 - multiple defines - misra-c - 21-09-2011

The defined operator is being used in one of the two standard forms. However, the normative text that accompanies the rule also states that generation of the token "defined" during expansion of #if or #elif leads to undefined behaviour [C90 Undefined 47] and shall therefore be avoided. It also provides an example of this.

Therefore, the code fragment is not permissible under Rule 19.14.