13 #define offsetof(TYPE, MEMB) ((size_t) &((TYPE *)0)->MEMB)
16 struct bf mybf = { 0xffffffff, 4097, 65537, 5, 0xff, 4.5, 257 };
19 dumpMem(&mybf, sizeof mybf);
20 printf("sizeof mybf %d\n", sizeof mybf);
21 printf("offset a = %d\n", offsetof(struct bf, a));
22 printf("offset c = %d\n", offsetof(struct bf, c));
23 printf("offset d = %d\n", offsetof(struct bf, d));
26 printf("int a (expected -1): %d\n", mybf.a);
27 printf("unsigned x:13 (expected 4097): %u\n", mybf.x);
28 printf("unsigned y:17 (expected 65537): %u\n", mybf.y);
29 printf("unsigned y:3 (expected 5): %u\n", mybf.z);
30 printf("char c (expected ff): %x\n", mybf.c);
31 printf("double d (expected 4.5): %.1f\n", mybf.d);
32 printf("unsigned w:9 (expected 257): %u\n", mybf.w);