here is a little feature that allows you to save a little space.
main() { struct Flags { unsigned int Online :1; unsigned int Mounted :1; } struct Flags TapeInfo; TapeInfo.Online = 1; TapeInfo.Mounted = 0; } |
- You may expect the compiler to reserve 2 bytes for the structure, it actually reserves one word (usually 4 bytes) as this is the smallest unit that can be reserved, the remaining 2 bytes are unavailable. This is still better than the 2 words that wold normally get reserved.
- You can put any number into the variable, if the number is too large to fit, the high order bits are lost without warning.
- Only signed int, unsigned int, int support this syntax.