MISRA Discussion Forums

Full Version: Rule 20.8 and #elif
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
It is pretty clear from the Amplification that this is not a violation of Rule 20.8:
Code:
#if 0
  #if 10  /* not evaluated, not a violation */
  #endif
#endif
and that this is:
Code:
#if 0
#elif 20  /* evaluated, violation */
#endif
but is the following intended to be a violation of this rule?:
Code:
#if 1
#elif 20  /* ??? */
#endif
It is not clear if the preprocessing directive #elif 20 is evaluated for the purpose of this rule.
Code:
#if 1
#elif 20  /* rule 20.8 does not apply */
#endif
The #elif is considered to be in the code that is excluded and does not affect whether the code is excluded or not. Therefore the rule does not apply to the #elif controlling expression.