C++ anonymous structs
问题 I use the following union to simplify byte, nibble and bit operations: union Byte { struct { unsigned int bit_0: 1; unsigned int bit_1: 1; unsigned int bit_2: 1; unsigned int bit_3: 1; unsigned int bit_4: 1; unsigned int bit_5: 1; unsigned int bit_6: 1; unsigned int bit_7: 1; }; struct { unsigned int nibble_0: 4; unsigned int nibble_1: 4; }; unsigned char byte; }; It works nice, but it also generates this warning: warning: ISO C++ prohibits anonymous structs [-pedantic] Ok, nice to know. But.