* Bitfields in structures
@ 2002-09-27 7:23 John O'Connor
2002-09-27 8:22 ` John Love-Jensen
0 siblings, 1 reply; 2+ messages in thread
From: John O'Connor @ 2002-09-27 7:23 UTC (permalink / raw)
To: gcc-help
Please consider the two almost identical structures below for a structure
for PortE of Hitachi SH7045F 32-bit MCU. GNU C compiler objects to 3-bit
bitfield being called 'NIB' but does not object to it being called 'B3' !!!!
B3 works fine but get message saying 'Structure has no memeber called NIB',
when this field is named NIB. I cannot understand why this should be. Maybe
something very subtle going on here? Any help or advice will be most
appreciated.
Regards,
John O'Connor
struct st_pe { /* struct PE */
union { /* PEDR */
unsigned short WORD; /* Word Access */
struct { /* Bit Access */
unsigned char B15:1; /* Bit 15 */
unsigned char B14:1; /* Bit 14 */
unsigned char B13:1; /* Bit 13 */
unsigned char B12:1; /* Bit 12 */
unsigned char B11:1; /* Bit 11 */
unsigned char B10:1; /* Bit 10 */
unsigned char B9 :1; /* Bit 9 */
unsigned char B8 :1; /* Bit 8 */
unsigned char B7 :1; /* Bit 7 */
unsigned char B6 :1; /* Bit 6 */
unsigned char B5 :1; /* Bit 5 */
unsigned char B4 :1; /* Bit 4 */
unsigned char B3 :3; /* Bits 3,2,1 */
unsigned char B0 :1; /* Bit 0 */
} BIT; /* */
} DR; /* */
};
struct st_pe { /* struct PE */
union { /* PEDR */
unsigned short WORD; /* Word Access */
struct { /* Bit Access */
unsigned char B15:1; /* Bit 15 */
unsigned char B14:1; /* Bit 14 */
unsigned char B13:1; /* Bit 13 */
unsigned char B12:1; /* Bit 12 */
unsigned char B11:1; /* Bit 11 */
unsigned char B10:1; /* Bit 10 */
unsigned char B9 :1; /* Bit 9 */
unsigned char B8 :1; /* Bit 8 */
unsigned char B7 :1; /* Bit 7 */
unsigned char B6 :1; /* Bit 6 */
unsigned char B5 :1; /* Bit 5 */
unsigned char B4 :1; /* Bit 4 */
unsigned char NIB:3; /* Bits 3,2,1 */
unsigned char B0 :1; /* Bit 0 */
} BIT; /* */
} DR; /* */
};
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Bitfields in structures
2002-09-27 7:23 Bitfields in structures John O'Connor
@ 2002-09-27 8:22 ` John Love-Jensen
0 siblings, 0 replies; 2+ messages in thread
From: John Love-Jensen @ 2002-09-27 8:22 UTC (permalink / raw)
To: John O'Connor, gcc-help
Hi John,
Try this before the structure...
#undef NIB
...or...
#ifdef NIB
#error Hey, who defined NIB on me? Why I oughtta...!
#endif
If the latter, poke around your included header files.
--Eljay
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-09-27 15:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-27 7:23 Bitfields in structures John O'Connor
2002-09-27 8:22 ` John Love-Jensen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).