spacepaste

  1.  
  2. #include <stdio.h>
  3. typedef union
  4. {
  5. unsigned short M;
  6. struct
  7. {
  8. unsigned short :15;
  9. unsigned short c1:1;
  10. }S;
  11. }k_o;
  12. typedef union __attribute__((packed, scalar_storage_order("big-endian")))
  13. {
  14. unsigned short M;
  15. struct __attribute__((packed, scalar_storage_order("big-endian")))
  16. {
  17. unsigned short :15;
  18. unsigned short c1:1;
  19. }S;
  20. }k_o_gcc;
  21. int main()
  22. {
  23. k_o ko = { .M=0 };
  24. ko.S.c1 = 1;
  25. printf("old struct = %d\n", ko.M);
  26. k_o_gcc kogcc = { .M=0 };
  27. kogcc.S.c1 = 1;
  28. printf("new struct = %d\n", kogcc.M);
  29. return 0;
  30. }
  31.