Move debug macros to private header files

This commit is contained in:
c9s 2015-11-17 21:24:36 +08:00
parent a2f5205bc5
commit 3808cb37aa
4 changed files with 21 additions and 17 deletions

View file

@ -8,7 +8,6 @@
#ifndef DEFINE_H #ifndef DEFINE_H
#define DEFINE_H #define DEFINE_H
#include <stdbool.h> #include <stdbool.h>
#if !defined(bool) && !defined(__cplusplus) #if !defined(bool) && !defined(__cplusplus)
typedef unsigned char bool; typedef unsigned char bool;
#endif #endif
@ -18,20 +17,4 @@ typedef unsigned char bool;
#ifndef TRUE #ifndef TRUE
# define TRUE 1 # define TRUE 1
#endif #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 */ #endif /* !DEFINE_H */

View file

@ -12,6 +12,7 @@
#include "r3_slug.h" #include "r3_slug.h"
#include "slug.h" #include "slug.h"
#include "str.h" #include "str.h"
#include "r3_debug.h"
#include "zmalloc.h" #include "zmalloc.h"
#ifdef __GNUC__ #ifdef __GNUC__

19
src/r3_debug.h Normal file
View file

@ -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 */

View file

@ -11,6 +11,7 @@
#include "r3.h" #include "r3.h"
#include "r3_slug.h" #include "r3_slug.h"
#include "slug.h" #include "slug.h"
#include "r3_debug.h"
#include "zmalloc.h" #include "zmalloc.h"