次のユニオンを使用して、バイト、ニブル、およびビット操作を簡素化します。
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;
};
うまく機能しますが、次の警告も生成されます。
警告: ISO C++ は無名構造体を禁止しています [-pedantic]
わかりました。しかし...私のg ++出力からこの警告を取得するにはどうすればよいですか? この問題なしでこのユニオンのようなものを書く可能性はありますか?