union {
struct {
unsigned b0:1;
unsigned b1:1;
unsigned b2:1;
unsigned b3:1;
unsigned b4:1;
unsigned b5:1;
unsigned b6:1;
unsigned b7:1;
}oneBit;
unsigned char allBits;
} myFlag;
#define fast myFlag.oneBit.b0
#define mid myFlag.oneBit.b1
#define slow myFlag.oneBit.b2
#define flow myFlag.oneBit.b3
#define voice myFlag.oneBit.b4
#define pause myFlag.oneBit.b5
#define white myFlag.oneBit.b6
#define on_off myFlag.oneBit.b7
#define mark myFlag.allBits
上面的语句在PICC中编译出来每一个占一个位,但在KEIL C中编译出来怎么占一个字节啊?如果在在KEIL C 中要实现如上功能,应该怎么写呢? |