1 #include <ccan/tcon/tcon.h>
2 #include <ccan/build_assert/build_assert.h>
10 struct val_container {
12 TCON(TCON_VALUE(fixed_val, 17));
23 struct offs_container {
25 TCON(TCON_VALUE(off1, offsetof(struct other_struct, x1));
26 TCON_VALUE(off2, offsetof(struct other_struct, x2)));
29 int main(int argc, char *argv[])
31 struct val_container valcon;
32 struct offs_container offscon;
33 TCON_WRAP(struct container, TCON_VALUE(fixed_val, 17)) valconw;
34 TCON_WRAP(struct container,
35 TCON_VALUE(off1, offsetof(struct other_struct, x1));
36 TCON_VALUE(off2, offsetof(struct other_struct, x2))) offsconw;
38 BUILD_ASSERT(tcon_value(&valcon, fixed_val) == 17);
39 BUILD_ASSERT(tcon_value(&valconw, fixed_val) == 17);
41 BUILD_ASSERT(tcon_value(&offscon, off1)
42 == offsetof(struct other_struct, x1));
43 BUILD_ASSERT(tcon_value(&offscon, off2)
44 == offsetof(struct other_struct, x2));
45 BUILD_ASSERT(tcon_value(&offsconw, off1)
46 == offsetof(struct other_struct, x1));
47 BUILD_ASSERT(tcon_value(&offsconw, off2)
48 == offsetof(struct other_struct, x2));