This code will compile on all compilers, but it is poor programming. The above is called "bit fields", and bit fields are [italic]very[/italic] poorly defined by the standard. The only allowed type is int, you cannot use them with any other type.

And you shouldn't use them, but know that they exist. Sadly, they are very commonly used by so-called programmers in embedded systems.

You shouldn't use them because of the following reasons (advanced topic, beginners may stop reading here :-)):

- You don't know if the first bit in the struct is msb or lsb.- You don't know how the bits are stored in memory.- The code will be little/big endian dependant.- You don't know whether "int" will be treated as signed or unsigned.- You don't know if arrays of bit fields will work or not.- Padding bytes are allowed inside bit fields.- There is a risk that beginner programmers use other types than int for bit fields, which is undefined behavior in the standard and will cause the code to behave completely randomly.

Since you can only work on byte level on most computers, you need to mask out the bit you are interested in, in this case bit 5, since 0x20 equals bit number 5. You mask out this bit without destroying the other bits. That's when the bitwise OR (|) and AND (&) operators comes in.

Needless to say, you must understand binary and hexadecimal numbers before starting to learn any form of programming.