bitfields

John P. Nelson jpn at teddy.UUCP
Mon Dec 1 22:57:44 AEST 1986


>Ok, folks, here is the burining question of the hour:  how are bit fields in
>C dealt with?  As I read K&R arrays of bit fields are allowed, HOWEVER, in
>the Microsoft C compiler Version 4.0, they explicitly state that they are not
>allowed.

If K&R is Kernighan and Ritchie, I suggest you reread it.  Arrays of bitfields
are EXPLICITLY disallowed  (See the last paragraph in section 6.7) - but in
any case, an array of bitfields is impossible, not just difficult - Remember
that a reference to an array (not just an element of it) evaluates to an
ADDRESS - However, taking the address of a bit field is also explicitly
disallowed.  Here is part of the relavent paragraph from K&R

     Other restritrictions (of bit fields) to bear in mind:  ...   They are
     not arrays; they do not have addresses, so the & operator cannot be
     applied to them.

and again, in appendix A where structures are formally defined (section 8.5):

     ... In all implementations, there are no arrays of fields, and the
     address-of operator '&' may not be applied to them, so that there are no
     pointers to fields.



More information about the Comp.unix.wizards mailing list