Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
14.3 and enum constants in macro expansion
#1
Hi,

We have a configuration macro with a value being an enum constant. We use that macro in an if-statement, and it violates the rule 14.3.

Code:
enum my_enum {
    MY_ENUM
};

#define CONF_MACRO MY_ENUM

if (CONF_MACRO == MY_ENUM) {...}


Note that in the case of enum constants we cannot convert the if-statement to a preprocessor #if-statement since the values of enum constants are not known at the preprocessing step. How can we solve this issue?
Reply
#2
It is recognised that, sometimes, violations of Guidelines will happen...

In this instance, MISRA C have published a permit [Permit / MISRA / C:2012 / R-14.3.A.1] which provides assistance in deviating Rule 14.3 due to build configurations.

https://www.misra.org.uk/app/uploads/202...dition.pdf
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)