Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!wuarchive!zaphod.mps.ohio-state.edu!maverick.ksu.ksu.edu!deimos.cis.ksu.edu!matt.ksu.ksu.edu!sirius From: sirius@matt.ksu.ksu.edu (James Hu) Newsgroups: comp.lang.c Subject: debugging macros (again) Summary: question, will optimizer squish null functions? Keywords: null function Message-ID: <270A7EC9.3ADD@deimos.cis.ksu.edu> Date: 4 Oct 90 00:14:01 GMT Sender: nntpd@deimos.cis.ksu.edu (USENET NNTP Server) Distribution: usa Organization: Kansas State University, Dept of Computing & Information Sciences Lines: 52 Hello. I remember debugging macros were discussed sometime last year, but I did not pay too close attention then. Could someone advise me via email if the following header file is ok? /* debug.h: My debugging macros */ #ifdef DEBUG # ifdef IN_MAIN_OBJECT # include int debug_level = 0; void BUG(int priority, char *fmt, ...) { va_list ap; if (priority < 0) return; if ((-debug_level != priority) && (debug_level < priority)) return; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } # else /* NOT MAIN */ extern int debug_level; extern void BUG(int, char *,...); # endif /* MAIN */ #else /* NOT DEBUG */ # ifdef IN_MAIN_OBJECT void BUG(int x, char *s,...) {} # else /* NOT MAIN */ extern void BUG(int, char *,...); # endif /* MAIN */ #endif /* DEBUG */ /* end of debug.h */ My primary concern, of course, is if the compiler will optimize the null function call down to doing nothing at all. Thanks for any help.