You could create
typedef struct foo
{
unsigned x:1;
} foo;
Where you have told the compiler that you'll only be using one bit of x
.
But due to structure packing arrangements (the C standard is intentionally flexible in order that compilers can optimise according to the machine architecture), it may well turn out that this still occupies as much space in memory as a regular unsigned
and an array of foo
s doesn't have to be bitwise contiguous.