2010年9月6日 星期一

define debug macro

in Configuration:
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [Enable debugging]),
CFLAGS="$CFLAGS -g -D_DEBUG")

Define:
#ifdef _DEBUG
#define DEBUG(format, args...) printf("[%s:%d] "format, __FILE__, __LINE__, ##args)
#else
#define DEBUG(args...)
#endif

Usage:
DEBUG("Debugging Mode was enabled\n")


Result:
[main.c:3] Debugging mode was enabled


Reference:
為你的程式加上 Debugging Mode

沒有留言: