MISRA Discussion Forums

Full Version: Rule 8.5 - #define with function code in header files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I would like to confirm the following interpretation of the rule 8.5. The rule says that "Header files should be used to declare objects, functions, typedefs, and macros. Header files shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage."

I have seen a couple of alerts in code raised when the header file contains a macro that generates the "body of one function". My understanding is that this is the case where the "macro produces definitions of objects or functions", and that this is a violation to be corrected.

In a similar way, if the header file contains a #typedef for an struct, should it be considered a violation to this rule?

Thanks in advance.
Header files which contain the typedef for a struct do not violate rule 8.5.

We are unclear what is meant to be "a macro that generates the body of one function", and so can not comment on that part of the question without an example.