我一直面临着这种 MISRA 违规行为:
定义:
#define A (1UL << 10)
#define INIT_A ((A) | (1UL << 15))
#define INIT_A_MASK (0xFFFFUL << 15)
#define IS_STATE_IFSET(state, val) ((((state) & (val##_MASK)) == (val)) ? true : false) //issue is here ?
来电者详情:
uint64_t state = 1234UL;
if (!IS_STATE_IFSET(state, INIT_A)) {
printf("Hoo-Haa\n");
}
Misra-2012 报告违反规则 20.12misra_c_2012_rule_20_12_violation: macro parameter "val" is used in both expanded and raw forms