#define DEBUG... (using printf for debugging)
Brad Staff
bjstaff at zds-ux.UUCP
Sat May 5 05:04:18 AEST 1990
I add some declarations that look something like the following:
#ifdef PRODUCTION
#define DEBUG 0
#else
int DEBUG = FLAG1 | FLAG2 | ... | FLAGn;
#endif /* PRODUCTION */
Then I do it like this:
if (DEBUG & FLAGx)
printf(...);
This way the debug statements look more like regular C code, which is more
aesthetically pleasing to my eyes. :-) This method allows you to turn debug
printfs on and off in a running system by patching the DEBUG variable with a
kernel debugger or adb. When you #define PRODUCTION, any compiler worth using
(IMHO) will optimize away both the test and the printf itself, for a zero
performance penalty.
--
Brad Staff |
Zenith Data Systems | "A government that can forbid certain
616-982-5791 | psychoactive drugs can mandate others."
bjstaff at zds-ux.zds.com | - Russell Turpin
More information about the Comp.unix.wizards
mailing list