Let's say I have this structure: struct PAINTSTRUCT { bool state; }
And somewhere in my main code I want to print out the value of state. But I also want to know what I'm printing out. So usually I'd do this: void main() { PAINTSTRUCT ps; writefln("ps.state = %s", ps.state); } Has anyone written a function which will automatically print out both the variable name and any object it might be part of, and then the value? E.g. I'd like to use a function like this: writeField(ps.state); And if state is false it would print out to the console: "ps.state = false" I can't really touch PRINTSTRUCT because it's already defined as a WinAPI structure and messing with that would be bad, so I can't implement toString() or any helper functions within the struct. I need an outside function which could do this automatically for any object/struct type.