Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8.9 and macros
#2
ISO C states that

\"An identifier currently defined as an object-like macro shall not be redefined by another #define preprocessing directive unless the second definition is an object-like macro definition and the two replacement lists are identical. Likewise, an identifier currently defined as a function-like macro shall not be redefined by another #define preprocessing directive unless the second definition is a function-like macro definition that has the same number and spelling of parameters, and the two replacement lists are identical.\"

So your example is indeed legal ISO C, while this is not:

#define BILL some text
#define BILL some other text

Only if they are identical are they allowed by ISO C. And if they are identical, they are also harmless, so I see no point in a MISRA rule forbidding that.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)