MISRA Discussion Forums
Does Directive 5.7.2 apply to #elif directives? - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=188)
+---- Forum: 4.5 Lexical conventions (https://forum.misra.org.uk/forumdisplay.php?fid=191)
+---- Thread: Does Directive 5.7.2 apply to #elif directives? (/showthread.php?tid=1708)



Does Directive 5.7.2 apply to #elif directives? - rg99 - 30-09-2024

Is the following intended to be compliant with 5.7.2?

Code:
#if 1
/* some code */
#elif 0
/* some code */
#endif

Presumably this is just as offensive to the spirit of 5.7.2 as #if 0 is but an official position would be appreciated as the Directive only actually mentions #if.


RE: Does Directive 5.7.2 apply to #elif directives? - misra cpp - 04-10-2024

You're right, it is equally bad.

We may have been too explicit in the description by saying "#if 0". In the next version this may be replaced by something more general, such asĀ  "The preprocessor shall also not be used to 'comment out' code"