From: Ernst B. <e.b...@xe...> - 2006-09-07 08:41:21
|
Hi list, A little one-line patch to debug.h: -------------------- snip --------------- extern int running_background; extern int verbose_level; -void message(const int level, const char *format, ...); +void message(const int level, const char *format, ...) __attribute__((format (__printf__, 2, 3) )); #define debug(args...) message (2, __FILE__ ": " args) #define info(args...) message (1, args) ----------------- snip ------------------- It tells gcc that "message" takes a printf-like format string, so gcc can check if the varargs match. Saved me a lot of bug-hunting time for spurious segfaults caused by wrong debug statements. Should work with gcc 3.3.1 or later, probably earlier versions of gcc, too. One could add some gcc version-check #ifdefs arround it, but since other parts of the code already use __attribute__(( unused )) and the like, its probably not neccessary. /Ernst |