2 ms·
My Favorite Debugging Hack
- torstenvl 5y agoI love using macros for debugging like this. It lessens the mental hurdle, and it's easy to redefine the macro as ((void)0) in production code. Two adjustments I'd make in the linked code: (1) _Generic became part of the standard over a decade ago, so this can safely be just one macro (lessening the mental hurdle even more); and (2) I don't think do{...}while(0) is necessary here for a single fprintf() call.
- torstenvl 5y agoSince I said I'd have done it a little differently, let me go ahead and contribute this simple bit of code (hereby dedicated to the public domain): https://pastebin.com/qE3VyLrp https://pastebin.com/qE3VyLrp