From 3808cb37aab3f8e35ffcf16c3c3e8655fab4cf55 Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 17 Nov 2015 21:24:36 +0800 Subject: [PATCH] Move debug macros to private header files --- include/r3_define.h | 17 ----------------- src/node.c | 1 + src/r3_debug.h | 19 +++++++++++++++++++ src/slug.c | 1 + 4 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 src/r3_debug.h diff --git a/include/r3_define.h b/include/r3_define.h index 5fd30ed..f0903ee 100644 --- a/include/r3_define.h +++ b/include/r3_define.h @@ -8,7 +8,6 @@ #ifndef DEFINE_H #define DEFINE_H #include - #if !defined(bool) && !defined(__cplusplus) typedef unsigned char bool; #endif @@ -18,20 +17,4 @@ typedef unsigned char bool; #ifndef TRUE # define TRUE 1 #endif - -// #define DEBUG 1 -#ifdef DEBUG - -#define info(fmt, ...) \ - do { fprintf(stderr, fmt, ##__VA_ARGS__); } while (0) - -#define debug(fmt, ...) \ - do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ - __LINE__, __func__, __VA_ARGS__); } while (0) - -#else -#define info(...); -#define debug(...); -#endif - #endif /* !DEFINE_H */ diff --git a/src/node.c b/src/node.c index df217e6..d7e06ac 100644 --- a/src/node.c +++ b/src/node.c @@ -12,6 +12,7 @@ #include "r3_slug.h" #include "slug.h" #include "str.h" +#include "r3_debug.h" #include "zmalloc.h" #ifdef __GNUC__ diff --git a/src/r3_debug.h b/src/r3_debug.h new file mode 100644 index 0000000..20ac4e1 --- /dev/null +++ b/src/r3_debug.h @@ -0,0 +1,19 @@ +#ifndef R3_DEBUG_H +#define R3_DEBUG_H + +// #define DEBUG 1 +#ifdef DEBUG + +#define info(fmt, ...) \ + do { fprintf(stderr, fmt, ##__VA_ARGS__); } while (0) + +#define debug(fmt, ...) \ + do { fprintf(stderr, "%s:%d:%s(): " fmt, __FILE__, \ + __LINE__, __func__, __VA_ARGS__); } while (0) + +#else +#define info(...); +#define debug(...); +#endif + +#endif /* !DEBUG_H */ diff --git a/src/slug.c b/src/slug.c index d6702c5..19a6401 100644 --- a/src/slug.c +++ b/src/slug.c @@ -11,6 +11,7 @@ #include "r3.h" #include "r3_slug.h" #include "slug.h" +#include "r3_debug.h" #include "zmalloc.h"