小编Tom*_*Tom的帖子

有没有办法在C90标准中使用enum unsigned(符合MISRA-C 2004标准)

我正试图找到一种方法来使枚举"无符号".

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想要的特定枚举无符号?

c standards misra

3
推荐指数
3
解决办法
1万
查看次数

标签 统计

c ×1

misra ×1

standards ×1