Rule 2.5 vs. include guards - 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.2 Unused code (https://forum.misra.org.uk/forumdisplay.php?fid=157) +---- Thread: Rule 2.5 vs. include guards (/showthread.php?tid=1317) |
Rule 2.5 vs. include guards - sg2 - 27-02-2017 Hi. It is not completely clear what is meant by use of a macro in Rule 2.5. There is definition of a use of an expression in the Glossary, but not of a macro. If taken literally, rule 2.5 means that standard include guards are forbidden: #ifndef HEADER_H #define HEADER_H // Not used unless another #ifndef is encountered somewhere inside ... #endif Re: Rule 2.5 vs. include guards - misra-c - 30-03-2017 Your example is compliant with rule 2.5. The #ifndef HEADER_H is considered to be a use of the macro name, even though it appears before the #define. |