Hardly abusing or original, generating small chunks of code and invoking C compiler on each of these is how GNU autoconf works (and the reason it works slow, too!)
<a href="http://perldoc.perl.org/pstruct.html" rel="nofollow">http://perldoc.perl.org/pstruct.html</a> takes this a bit further (but less portably), and compiles the code to assembly and parses out the debug records to find the information about the structures.