Except for the often-frowned-upon way of including #ifdef's in a .c file, there are two ways to include debug code in a program:
1. In xxx.h:
And in xxx.c:Code:#ifdef DEBUG void debugprint(const char *s); #else static inline debugprint(const char *dummy) {} #endif
2. In xxx.c:Code:int somefunction(...) { ... debugprint("...debug info..."); ... }
The second method can test all possible execution paths of a program during compile time but the code is littered with "if (DEBUG)". DEBUG is defined in a command-line compiler option (-D). What one is better? Thank you.Code:int somefunction(...) { ... if (DEBUG) debugprint("...debug info..."); ... }



LinkBack URL
About LinkBacks


