diff --git a/src/common.h b/src/common.h index 87d5005..d064dc5 100644 --- a/src/common.h +++ b/src/common.h @@ -1,7 +1,9 @@ #ifndef COMMON_H_ #define COMMON_H_ +#include #include +#include #include #define __DCURL_MAJOR__ 0 @@ -10,6 +12,15 @@ double diff_in_second(struct timespec t1, struct timespec t2); +static inline void ddprintf(const char *format, ...) { +#if defined(ENABLE_DEBUG) + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); +#endif +} + typedef struct _pow_info PoW_Info; struct _pow_info { diff --git a/src/implcontext.c b/src/implcontext.c index d09dbc3..711f884 100644 --- a/src/implcontext.c +++ b/src/implcontext.c @@ -14,12 +14,10 @@ bool registerImplContext(ImplContext *impl_ctx) bool initializeImplContext(ImplContext *impl_ctx) { bool res = impl_ctx->initialize(impl_ctx); -#if defined(ENABLE_DEBUG) if (res) { - printf(MSG_PREFIX "Implementation %s is initialized successfully\n", - impl_ctx->description); + ddprintf(MSG_PREFIX "Implementation %s is initialized successfully\n", + impl_ctx->description); } -#endif return res; }