MISRA Discussion Forums
Clarification on Rule 20.8 - 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:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.14 Control statement expressions (https://forum.misra.org.uk/forumdisplay.php?fid=169)
+---- Thread: Clarification on Rule 20.8 (/showthread.php?tid=1162)



Clarification on Rule 20.8 - anuj1085 - 05-03-2015

In the below case

#if 10
----
#elif 20
----
#endif

Since the part of the code
#elif 20
----
#endif

Is never gonna execute, is the rule applicable to this part of code i.e the part #elif 20 will be ignored while compilation so should the violation should be reported on it ?


Re: Clarification on Rule 20.8 - misra-c - 13-03-2015

The amplification of rule 20.8 states:
Quote: This rule does not apply to controlling expressions in preprocessing directives which are not evaluated. Controlling expressions are not evaluated if they are within code that is being excluded and cannot have an effect on whether code is excluded or not.
Therefore this rule does not apply to the "#elif 20". However the "#if 10" is a violation of rule 20.8