From 710745262d2d76c5613f188af1603baf0e9b2b8b Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Fri, 28 Aug 2009 10:46:17 +0000 Subject: [PATCH] Define useful messaging macros. WARNING: It use C99 syntax (__VA_ARGS__) and GNU extension (##), some tweaks may be needed to support non-C99 and non-GNU compiler. --- src/defines.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/defines.h b/src/defines.h index a604a7b..9b9f94d 100644 --- a/src/defines.h +++ b/src/defines.h @@ -30,6 +30,17 @@ typedef void* dev_spec; // Device connection specification #define MAX_DEVICES 16 // Useful macros +#ifdef DEBUG +// #define DBG(x, args...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__,## args ) + #define DBG(x, ...) printf("DBG %s:%d: " x "\n", __FILE__, __LINE__, ## __VA_ARGS__ ) +#else + #define DBG(...) {} +#endif + +#define INFO(x, ...) printf("INFO: " x "\n", ## __VA_ARGS__ ) +#define WARN(x, ...) printf("WARNING: " x "\n", ## __VA_ARGS__ ) +#define ERR(x, ...) printf("ERROR: " x "\n", ## __VA_ARGS__ ) + //#define MIN(a,b) (((a) < (b)) ? (a) : (b)) //#define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define INNER_XOR8(n) {n ^= (n >> 4); n ^= (n >> 2); n ^= (n >> 1); n &= 0x01; }