Rule 19.14 - multiple defines

6.19 Preprocessing Directives

Moderators: misra-c, david ward

Post Reply
Posts: 3
Joined: Tue Sep 13, 2011 8:11 am
Company: Secure Meters (UK)

Rule 19.14 - multiple defines

Post by JohnC » Thu Sep 15, 2011 6:55 pm

Is this permissible under rule 19.14?

Code: Select all

#define X ((defined(Y)) || (defined(Z)))
#if X

Posts: 572
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 19.14 - multiple defines

Post by misra-c » Wed Sep 21, 2011 10:12 am

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

Post Reply

Return to “6.19 Preprocessing Directives”