分类: C/C++
2008-04-25 14:25:15
#include struct a { union { int offset_global; struct { int offset_part1:31; /*低位*/ int offset_part2:1; /*高位*/ }; }; int b; }; int main() { struct a test; test.b = 1; test.offset_global = 1; printf("%d %d\n", test.offset_part1, test.offset_part2); return 0; } |
#include struct a { union u1 { int offset_global; struct { int offset_part1:31; /*低位*/ int offset_part2:1; /*高位*/ }; } offset; int b; }; int main() { struct a test; test.b = 1; test.offset.offset_global = 1; printf("%d %d\n", test.offset.offset_part1, test.offset.offset_part2); return 0; } |