Joined: 08 Sep 2003 Posts: 105 Location: New Castle, DE
Struct number of bits out of range error
Posted: Mon Feb 28, 2011 1:18 pm
Hello
Can someone tell me why this?
If I define the struct with element 2 as 4 bits it compiles without an issue.
Code:
struct wwvbtime { //top 32 bits received
int nu1; //top 8 bits of 32 not used
int nu2 :4; //next 7 bits of 32 not used
int mt :3; //tens of minutes
int nu3 :1; //one bit not used
int m :4; //minutes
int nu4 :2; //two bits not used
int ht :2; //tens of hours
int nu5 :1; //one bit not used
int h :4; //hours
} rxhigh;
But if I replace the 4 bits with 7 bits I get a compiler error.
"Number of bits is out of range"
With 7 bits in element 2 would make the total bits in the struct = 32.
Code:
struct wwvbtime { //top 32 bits received
int nu1; //top 8 bits of 32 not used
int nu2 :7; //next 7 bits of 32 not used
int mt :3; //tens of minutes
int nu3 :1; //one bit not used
int m :4; //minutes
int nu4 :2; //two bits not used
int ht :2; //tens of hours
int nu5 :1; //one bit not used
int h :4; //hours
} rxhigh;
Compiler 4.119 PIC18F4550
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Mon Feb 28, 2011 2:38 pm
You may have to email CCS for a clarification on this.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum