MISRA C:2012 Rule 20.5 applicable for inactive code ? - 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.20 Preprocessing directives (https://forum.misra.org.uk/forumdisplay.php?fid=175) +---- Thread: MISRA C:2012 Rule 20.5 applicable for inactive code ? (/showthread.php?tid=1521) |
MISRA C:2012 Rule 20.5 applicable for inactive code ? - Girish - 06-01-2020 Hello, MISRA C:2012 Rule 20.5 - #undef should not be used. For the following code snippet, #undef is seen at line 5 and 8. As Rule 20.5 complains for use of #undef, please let us know whether code at line 8, which is inactive code due to #else is Non-compliant or not according MISRA C:2012 Rule 20.5 ? 1. #define FLAG 100 2. 3. #ifdef FLAG 4. #define L 0 5. #undef L 6. #else 7. #define X 0 8. #undef X 9. #endif Regards Girish.M RE: MISRA C:2012 Rule 20.5 applicable for inactive code ? - misra-c - 01-07-2024 The Glossary defines Code as "Code consists of everything within a translation unit that is not excluded by conditional compilation" As such, the #undef at line 8 is excluded from analysis - that does not make it compliant or non-compliant |