Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 19.14 - multiple defines
#1
Is this permissible under rule 19.14?

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

JohnC.
<t></t>
Reply
#2
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.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)