-
- #include <stdio.h>
-
- typedef union
- {
- unsigned short M;
- struct
- {
- unsigned short :15;
- unsigned short c1:1;
- }S;
- }k_o;
-
- typedef union __attribute__((packed, scalar_storage_order("big-endian")))
- {
- unsigned short M;
- struct __attribute__((packed, scalar_storage_order("big-endian")))
- {
- unsigned short :15;
-
- unsigned short c1:1;
- }S;
- }k_o_gcc;
-
- int main()
- {
- k_o ko = { .M=0 };
- ko.S.c1 = 1;
- printf("old struct = %d\n", ko.M);
- k_o_gcc kogcc = { .M=0 };
- kogcc.S.c1 = 1;
- printf("new struct = %d\n", kogcc.M);
- return 0;
- }
-