如此便可!!
struct bit_def {
char b0:1;
char b1:1;
char b2:1;
char b3:1;
char b4:1;
char b5:1;
char b6:1;
char b7:1;
char b8:1
char b9:1
......
};
struct byte_def{
char byteh:8
char bytel:8
}
union byte_def{
struct bit_def bit;
char byte;
struct byte_def byte;
};
example:
union byte_def tabsr_addr;
#define tabsr tabsr_addr.byte
#define ta0s tabsr_addr.bit.b0
#define ta1s tabsr_addr.bit.b1
#define ta2s tabsr_addr.bit.b2
#define ta3s tabsr_addr.bit.b3
#define ta4s tabsr_addr.bit.b4
#define tb0s tabsr_addr.bit.b5
#define tb1s tabsr_addr.bit.b6
#define tb2s tabsr_addr.bit.b7
......
#define tbbytel tabsr_adr.byte.bytel
#define tbbyteh tabsr_adr.byte.byteh
以后引用就直接用了。
比如
tabbyteh=0x45;
tab1=1;
............
发表时间:2002年10月24日16:07:00