Skip to main content

Practice ยท 2 of 4

Append-Only Versioning

CHALLENGE
Difficulty: advanced+25 XP

Old struct in your editor: struct cfg_v1 { int mode; int level; };. Implement size_t cfg_v1_size(void) returning sizeof(struct cfg_v1), and โ€” defining struct cfg_v2 { int mode; int level; int flags; int reserved; }; โ€” int cfg_v2_prefix_compatible(void) returning 1 iff the v2 members that v1 knew sit at identical offsets (verify with offsetof, do not hardcode 1).

Back to lesson: Practice: ABI Contract Drills