-
syntax error
why am i getting the error
synatx error before ":"
void main()
{
int i:3;
}
now when in memory what will be the size of the integer will it be of 4 bytes or will it take 3 bits actually.
also if i have to use similar ones like int i:3,j:4:k:1
now how do i access i,j,k individually
-
You can only use bit fields in structs (that's way the compiler complains about a syntax error):
Code:
struct MYBITFIELD
{
unsigned int i:3;
unsigned int j:4;
unsigned int k:1;
}
bit;
you can access these fields using the dot "." operator: bit.i
The amount of memory used depends on the compiler, but usually the components of the bitfield are packed in units of size "sizeof(int)".
alex