...
代码块 |
---|
typedef enum State { StateA = 1 << 0, StateB = 1 << 1, StateC = 1 << 2, ... StateX = 1 << 8 // 错误,超出char类型范围了 } STATE_E; |
对此,只能将枚举值转化为宏定义,如下:
代码块 |
---|
typedef unsigned int STATE_E;
#define StateA (1 << 0)
...
#define StateX (1 << 8) |
...
...
代码块 |
---|
typedef enum State { StateA = 1 << 0, StateB = 1 << 1, StateC = 1 << 2, ... StateX = 1 << 8 // 错误,超出char类型范围了 } STATE_E; |
对此,只能将枚举值转化为宏定义,如下:
代码块 |
---|
typedef unsigned int STATE_E;
#define StateA (1 << 0)
...
#define StateX (1 << 8) |
...