fork download
  1. #include <iostream>
  2. #include <inttypes.h>
  3.  
  4. enum MyEnum {Test, Enum, Flags};
  5.  
  6. union BitField
  7. {
  8. unsigned int one : 16;
  9. MyEnum two : 8;
  10. signed int three : 7;
  11. bool four : 1;
  12. };
  13.  
  14. int main()
  15. {
  16. std::cout << "sizeof(BitField) == " << sizeof(BitField) << std::endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
sizeof(BitField) == 4