Am new here, and although this post is a bit old, I have decided to contribute a simple solution to this problem.
I know that this isn't the most optimized technique, considering that this is no way to directly address a bit on the Intel architecture, which uses byte addressing, so this isn't something that you would want to use if you needed fast or small code.
Solution -- Bit Fields
#include <stdio.h>
#pragma(1)
typedef struct _bits_t {
unsigned bit0 : 1;
unsigned bit1 : 1;
unsigned bit2 : 1;
unsigned bit3 : 1;
unsigned bit4 : 1;
unsigned bit5 : 1;
unsigned bit6 : 1;
unsigned bit7 : 1;
} bits_t;
#pragma()
int main(int argc, char *argv[])
{
unsigned byte = 0xAE;
bits_t *bits;
bits = &byte;
printf("%d%d%d%d %d%d%d%d", x->bit7, x->bit6, x->bit5, x->bit4, x->bit3, x->bit2, x->bit1, x->bit0);
return 0;
}
Doing it this way may have its obvious downsides, but it definitely makes bit checking/manipulation a hell of a lot easier.
So what do you all think?