Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8.9 and macros
#6
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.
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)