[niepce: 12/22] Added DBG_DTOR facility



commit fa1efbb893b8a38d5c6eddb559bade9d88e15269
Author: Hubert Figuière <hub figuiere net>
Date:   Fri Jul 25 22:12:30 2014 +0200

    Added DBG_DTOR facility

 src/fwk/base/debug.hpp |   43 ++++++++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/fwk/base/debug.hpp b/src/fwk/base/debug.hpp
index cc9197f..96e0571 100644
--- a/src/fwk/base/debug.hpp
+++ b/src/fwk/base/debug.hpp
@@ -17,6 +17,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#pragma once
+
 #ifndef __FWK_BASE_DEBUG_H__
 #define __FWK_BASE_DEBUG_H__
 
@@ -25,7 +27,7 @@
 #endif
 
 #ifdef __GNUC__
-// we have too mark this as a system header because otherwise GCC barfs 
+// we have too mark this as a system header because otherwise GCC barfs
 // on variadic macros.
 #pragma GCC system_header
 #endif
@@ -33,34 +35,37 @@
 namespace fwk {
 
 #ifdef DEBUG
+
 #define DBG_OUT(x, ...) \
        fwk::dbg_print(x,  __FUNCTION__, ## __VA_ARGS__)
-#else
-#define DBG_OUT(x, ...)        
-#endif
-
-#ifdef DEBUG
 #define DBG_ASSERT(cond, reason)       \
        fwk::dbg_assert(cond, #cond, __FUNCTION__, __FILE__, __LINE__, reason)
+#define DBG_DTOR \
+    DBG_OUT("dtor %p", this)
+
 #else
+
+#define DBG_OUT(x, ...)
 #define DBG_ASSERT(cond, reason)       \
        assert(cond)
+#define DBG_DTOR
+
 #endif
 
 #define ERR_OUT(x, ...) \
     fwk::err_print(x,  __FUNCTION__, __FILE__, __LINE__, ## __VA_ARGS__)
 
 
-       /** print debug messages. printf format.
-        * NOOP if DEBUG is not defined.
-        * Call with the DBG_OUT macro
-        * @param fmt the formt string, printf style
-        * @param func the func name
-        */
-       void dbg_print(const char* fmt, const char* func, ...)
+/** print debug messages. printf format.
+ * NOOP if DEBUG is not defined.
+ * Call with the DBG_OUT macro
+ * @param fmt the formt string, printf style
+ * @param func the func name
+ */
+void dbg_print(const char* fmt, const char* func, ...)
     __attribute__ ((format (printf, 1, 3)));
 
-/** assert 
+/** assert
  * @param condvalue the value of the assert, true, assert
  * @param cond the text of the condition
  * @param func the function it happens in __FUNCTION__
@@ -72,11 +77,11 @@ void dbg_assert(bool condvalue, const char* cond, const char* func,
                 const char* filen,
                 int linen, const char* reason);
 
-       /** print error message. printf format.
-        * Call with the ERR_OUT macro.
-        * @param fmt the formt string, printf style
-        * @param func the func name
-        */
+/** print error message. printf format.
+ * Call with the ERR_OUT macro.
+ * @param fmt the formt string, printf style
+ * @param func the func name
+ */
 void err_print(const char *fmt, const char* func, const char* filen,
                int linen, ...)
     __attribute__ ((format (printf, 1, 5)));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]