2 ms·
That's why C has bit fields. It effectively lets you access individual (or clumps) of bits as elements of a struct. Now while this may not be as "convenient" a
by winter_blue 14y ago
That's why C has bit fields. It effectively lets you access individual (or clumps) of bits as elements of a struct.
Now while this may not be as "convenient" as array-style indexing, it definitely is orders of magnitude better than using bit masks and what not. You could also argue forcing to name each clump of bits (as a bit field struct forces you to) is a good thing, because most of the time the use case calls for something like this, and simply numerically indexing into bits might not be the most readable approach.