fork download
  1. #include <iostream>
  2. struct S {
  3. // will usually occupy 2 bytes:
  4. // 3 bits: value of b1
  5. // 2 bits: unused
  6. // 6 bits: value of b2
  7. // 2 bits: value of b3
  8. // 3 bits: unused
  9. unsigned char b1 : 3;
  10. unsigned char : 2; // How do you reference these?
  11. unsigned char b2 : 6, b3 : 2;
  12. };
  13. int main()
  14. {
  15. std::cout << sizeof(S) << '\n'; // usually prints 2
  16. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
2