Recently started hiding "... do" and "while (0);..." in macros to write nicely bracketed start and end C macros eg this set for generating HTML:
https://github.com/libguestfs/libguestfs-common/blob/master/...
You can write:
start_element ("memory") {
attribute ("unit", "MiB");
string_format ("%d", g->memsize);
} end_element ();
to generate <memory unit="MiB">1024</memory>