[求助]CodeWarrior不同版本编译成的结果不一样
- UID
- 517889
- 性别
- 男
|
[求助]CodeWarrior不同版本编译成的结果不一样
我参照芯片本身头文件定义了一个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版默认的对于字变量是高位字节在前???可以通过设置编译选项改为低位字节在前吗? |
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
编译出现的错误是什么错误?我相信4.6和4.7是一样的,都是高字节在低地址,而低字节在高地址。 |
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
编译没有出错,而是我烧写后调试发现原来正常的程序不对了,用仿真器在线看了下变量才发现的问题。 |
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
vO47H6Zs.rar (251.79 KB)
定义一个16位的变量,给最低位置1,结果用FCS看变量值为256!!! 用4.6版编译无此问题。
|
-
-
a1f53SP5.jpg
(23.45 KB)
DI纯水、EDI超纯水设备、软化水设备、RO中水回用设备、电子工业用超纯水设备、单/多晶硅水处理设
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
我试过了,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编辑过] |
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
试过还是不行啊。我就纳闷了,难道是哪里需要设置???? |
|
|
|
|
|
- UID
- 104380
- 性别
- 男
|
|
|
|
|
|
- UID
- 517889
- 性别
- 男
|
我晕,怀疑是操作系统的问题,所以在台式机和笔记本上都装了,也不行啊。。。到底什么原因!!! |
|
|
|
|
|