PICC位段编译问题,bad bitfield type

[复制链接]
3973|6
 楼主| busdriver 发表于 2010-11-3 09:12 | 显示全部楼层 |阅读模式
定义了一个4字节union,包含位段,但是编译的时候出现错误如下,
Error   [264] D:\Projects\clock_module\firmware\lmk04031.h; 49.20 bad bitfield type
Error   [264] D:\Projects\clock_module\firmware\lmk04031.h; 50.20 bad bitfield type
Error   [264] D:\Projects\clock_module\firmware\lmk04031.h; 51.19 bad bitfield type

附上源代码

typedef volatile unsigned long int ulint32;

union
{
  ulint32 R;
  struct
  {
   ulint32 ADDR:4;//address
   ulint32 CLKout_DLY:4;//clock channel delay control bits value
   ulint32 CLKout_DIV:8;//clock channel divide value
   ulint32 EN_CLKout:1;//clock channel output enable control bit
   ulint32 CLKout_MUX:2;//clock channel multiplexer control bits
   ulint32 CLKout_STATE:4;//state control bits for LVCMOS modes,0000 reserved due to LVDS output
   ulint32 CLKout_PECL_LVL:1;//LVPECL output format control,invalid due to LVDS output
   ulint32 reserved:8;//reserved values 0x01
  }B;
}R0;//R0 register
请大家分析一二,非常感谢,50分献上!
 楼主| busdriver 发表于 2010-11-3 15:13 | 显示全部楼层
搞定。
1.HT PICC中bitfield只支持int 类型。
(264) bad bitfield type  (Parser)
A bitfield may only have a type of int (signed or unsigned), e.g.:
struct FREG {
  char b0:1;   /* these must be part of an int, not char */
  char   :6;
  char b7:1;
} freg;

解决方法:将原32位寄存器拆分为高16位和低16位。
使用bitfield注意:
1)   一个位域必须存储在同一个字节中,不能跨两个字节。
2) 由于位域不允许跨两个字节,因此位域的长度不能大于一个字节的长度8。
 楼主| busdriver 发表于 2010-11-4 21:38 | 显示全部楼层
没人回答啊
yewuyi 发表于 2010-11-5 08:52 | 显示全部楼层
你已经自己搞定了还要别人回答干什么?
yewuyi 发表于 2010-11-5 08:52 | 显示全部楼层
PICC是支持unsigned long int 类型的。
 楼主| busdriver 发表于 2010-11-8 14:13 | 显示全部楼层
但是bitfield不支持long int type,编译提示仅支持int type,谢谢!
 楼主| busdriver 发表于 2010-11-8 14:14 | 显示全部楼层
50给热心斑竹了。谢谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

44

主题

416

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部