21-05-2008, 12:43 PM
Since macros are processed during the preprocessing phase they have no linkage and are therefore not covered by rule 8.9. However, rule 5.7 states that "No identifier name should be reused" and this rule applies to all files used across a system. Macro names are identifiers and are covered by this rule.
It is a moot point whether an identical redefinition of a macro counts as a reuse or not. Within a single translation unit there is no issue with an identical redefinition. Across multiple units, the programmer's expectation is for all expansions of a given macro to behave in the same way, so again identical redefinition is not an issue. In either case, when the redefinition is not identical rule 5.7 will catch the unwanted behaviour.
It is a moot point whether an identical redefinition of a macro counts as a reuse or not. Within a single translation unit there is no issue with an identical redefinition. Across multiple units, the programmer's expectation is for all expansions of a given macro to behave in the same way, so again identical redefinition is not an issue. In either case, when the redefinition is not identical rule 5.7 will catch the unwanted behaviour.
Posted by and on behalf of the MISRA C Working Group