Generate code to dump C structs

‎What would be the best way to parse a given project and generate a function per struct type that prints that struct contents?

You can use libclang or libtooling for that.