我正试图找到一种方法来使枚举"无符号".
enum{
x1 = 0,
x2,
x3
};
uint8_t = x2; /* <--- PC-LINT MISRA-C 2004 will complain about mixing signed and unsigned here */
Run Code Online (Sandbox Code Playgroud)
当然,我可以添加一个类型转换来摆脱错误,这是耗时且容易出错的.
uint8_t = (uint8_t)x2; /* This works, but is a lot of extra work over the course of 1000s of lines of code*/
Run Code Online (Sandbox Code Playgroud)
那么,有没有办法让MISRA-C 2004想要的特定枚举无符号?