[Telepathy-commits] [telepathy-mission-control/master] Add DEBUG() macro

Alberto Mardegan alberto.mardegan at nokia.com
Wed Feb 25 06:43:24 PST 2009


Add a --enable-debug configuration flag to toggle generation of debug code.
---
 configure.ac    |    5 +++++
 src/mcd-debug.h |   15 +++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 767dda1..0abb173 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,6 +96,11 @@ done
 AC_SUBST(TEST_PYTHON)
 AM_CONDITIONAL([WANT_TWISTED_TESTS], test false != "$TEST_PYTHON")
 
+AC_ARG_ENABLE(debug,            [  --disable-debug               compile without debug code],[enable_debug=${enableval}], enable_debug=yes )
+if test "x$enable_debug" = "xyes"; then
+	CFLAGS="$CFLAGS -DENABLE_DEBUG"
+fi
+
 AC_ARG_ENABLE(cast-checks,      [  --disable-cast-checks         compile with GLIB cast checks disabled],[cchecks=${enableval}],cchecks=yes)
 if test "x$cchecks" = "xno"; then
 	CFLAGS="$CFLAGS -DG_DISABLE_CAST_CHECKS"
diff --git a/src/mcd-debug.h b/src/mcd-debug.h
index af6bf7f..5a34b91 100644
--- a/src/mcd-debug.h
+++ b/src/mcd-debug.h
@@ -31,6 +31,21 @@
 
 G_BEGIN_DECLS
 
+#undef DEBUG
+
+#ifdef ENABLE_DEBUG
+
+#define DEBUG(format, ...) do {             \
+    if (mcd_debug_get_level () > 0)         \
+        g_debug (format, ##__VA_ARGS__);    \
+} while (0)
+
+#else /* !defined ENABLE_DEBUG */
+
+#define DEBUG(format, ...) do {} while (0)
+
+#endif /* ENABLE_DEBUG */
+
 #define g_object_ref(obj)    (mcd_debug_ref (obj, __FILE__, __LINE__))
 #define g_object_unref(obj)  (mcd_debug_unref (obj, __FILE__, __LINE__))
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list