我参照芯片本身头文件定义了一个16位的变量。定义如下:
typedef union {
word Word;
struct {
word BITR0 :1;
word BITR1 :1;
word BITR2 :1;
word BITR3 :1;
word BITR4 :1;
word BITR5 :1;
word BITR6 :1;
word BITR7 :1;
word BITR8 :1;
word BITR9 :1;
word BITR10 :1;
word BITR11 :1;
word BITR12 :1;
word BITR13 :1;
word BITR14 :1;
word BITR15 :1;
} Bits;
} wFlag;
extern volatile wFlag _wINFLAG;
#define wINFLAG _wINFLAG.Word
#define wINFLAG_B0 _wINFLAG.Bits.BITR0
#define wINFLAG_B1 _wINFLAG.Bits.BITR1
#define wINFLAG_B2 _wINFLAG.Bits.BITR2
#define wINFLAG_B3 _wINFLAG.Bits.BITR3
#define wINFLAG_B4 _wINFLAG.Bits.BITR4
#define wINFLAG_B5 _wINFLAG.Bits.BITR5
#define wINFLAG_B6 _wINFLAG.Bits.BITR6
#define wINFLAG_B7 _wINFLAG.Bits.BITR7
#define wINFLAG_B8 _wINFLAG.Bits.BITR8
#define wINFLAG_B9 _wINFLAG.Bits.BITR9
#define wINFLAG_B10 _wINFLAG.Bits.BITR10
#define wINFLAG_B11 _wINFLAG.Bits.BITR11
#define wINFLAG_B12 _wINFLAG.Bits.BITR12
#define wINFLAG_B13 _wINFLAG.Bits.BITR13
#define wINFLAG_B14 _wINFLAG.Bits.BITR14
#define wINFLAG_B15 _wINFLAG.Bits.BITR15
用4.6版编译一切正常,换成4.7版编译后出现错误。对BITR0置1,结果发现字变量_wINFLAG的值变成了256,感觉好像是低位字节被当成了高位字节处理,是否4.7版默认的对于字变量是高位字节在前???可以通过设置编译选项改为低位字节在前吗?
编译出现的错误是什么错误?我相信4.6和4.7是一样的,都是高字节在低地址,而低字节在高地址。
版主又闭关了?????
vO47H6Zs.rar (251.79 KB)
定义一个16位的变量,给最低位置1,结果用FCS看变量值为256!!!
用4.6版编译无此问题。
我试过了,4.6和4.7应该是一样的。你可以这样试试:
typedef union {
word Word;
struct {
//word BITR0 :1;
//word BITR1 :1;
//word BITR2 :1;
//word BITR3 :1;
//word BITR4 :1;
//word BITR5 :1;
//word BITR6 :1;
//word BITR7 :1;
//word BITR8 :1;
//word BITR9 :1;
//word BITR10 :1;
//word BITR11 :1;
// word BITR12 :1;
// word BITR13 :1;
//word BITR14 :1;
//word BITR15 :1;
byte BITR0 :1;
byte BITR1 :1;
byte BITR2 :1;
byte BITR3 :1;
byte BITR4 :1;
byte BITR5 :1;
byte BITR6 :1;
byte BITR7 :1;
byte BITR8 :1;
byte BITR9 :1;
byte BITR10 :1;
byte BITR11 :1;
byte BITR12 :1;
byte BITR13 :1;
byte BITR14 :1;
byte BITR15 :1;
} Bits;
} wFlag;
[此贴子已经被作者于2008-8-25 18:07:33编辑过]
我晕,怀疑是操作系统的问题,所以在台式机和笔记本上都装了,也不行啊。。。到底什么原因!!!
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |