Regarding the structure with bit fields, I met the following phrase: it is unacceptable to create arrays of bit fields, bit fields do not have an address.

If we talk about the addresses of fields inside structures, then everything is more or less clear: the middle byte of the "integer" address cannot be, all the more so because the specific memory allocation depends on the implementation.

But with arrays it is not clear. What prevents me from creating an array of structures that have bit fields? If it's not about that, then what? I find it hard to imagine an array of instances of a single field structure. Or is it that bitfields themselves cannot have an array type?

    1 answer 1

    As far as I understand, creating an array of structures with bit fields, you will not achieve their “compact” packaging. Depending on the setting of the #pragma package , the structure even with one bit field will take up at least 1 byte.

    But at the same time, no one can prevent you from allocating any number of bytes in one heap, and writing a handler for it that allows you to write and read the value is bit-wise, working with this array of bytes is indexed like an array of bits. I suppose that it was the opportunity to realize this and became the reason for the absence in the language of special constructions for working with bits, as with an array.

    • I do not ask about the packing of bitmaps. I ask you to comment on what is written in the literature about the restrictions on the use of arrays and pointers in bit fields. - Modus