我正在使用枚举值来表示标志:
typedef enum
{
a = 0x00,
b = 0x01u, // the u has no influence, as expected
c = 0x02u, // the u has no influence, as expected
...
} enum_name;
volatile unsigned char* reg = SomeAddress;
*reg |= b;
根据MISRA-C:2004标准,不应使用带符号类型进行按位操作。不幸的是,我的编译器IAR将有符号整数(或short或char)用作枚举的底层类型,我能找到的唯一选项只涉及大小,而不涉及有符号性(“--enum-is-int”)。
volatile unsigned char *reg =(volatile unsigned char *)SomeAddress;
- M.M