From aae856a310628d24190bf15cdf1fa53ec1d5f377 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 30 Jul 2012 22:31:36 +0200 Subject: [PATCH] Silence compiler warnings (unused variables). When the logging is disabling, several compiler warnings regarding unused variables appear. With the cast to void and sizeof trick the warnings are silenced without causing any side effects. --- src/context-private.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/context-private.h b/src/context-private.h index 3ccf78f..6eccd97 100644 --- a/src/context-private.h +++ b/src/context-private.h @@ -32,6 +32,8 @@ extern "C" { #endif /* __cplusplus */ +#define UNUSED(x) (void)sizeof(x) + #ifdef ENABLE_LOGGING #define SYSERROR(context, errcode) dc_context_syserror (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, __FUNCTION__, errcode) #define ERROR(context, ...) dc_context_log (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) @@ -39,11 +41,11 @@ extern "C" { #define INFO(context, ...) dc_context_log (context, DC_LOGLEVEL_INFO, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) #define DEBUG(context, ...) dc_context_log (context, DC_LOGLEVEL_DEBUG, __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) #else -#define SYSERROR(context, errcode) -#define ERROR(context, ...) -#define WARNING(context, ...) -#define INFO(context, ...) -#define DEBUG(context, ...) +#define SYSERROR(context, errcode) UNUSED(context) +#define ERROR(context, ...) UNUSED(context) +#define WARNING(context, ...) UNUSED(context) +#define INFO(context, ...) UNUSED(context) +#define DEBUG(context, ...) UNUSED(context) #endif dc_status_t