diff --git a/include/r3_define.h b/include/r3_define.h new file mode 100644 index 0000000..bee91da --- /dev/null +++ b/include/r3_define.h @@ -0,0 +1,36 @@ +/* + * r3_define.h + * Copyright (C) 2014 c9s + * + * Distributed under terms of the MIT license. + */ + +#ifndef DEFINE_H +#define DEFINE_H + +#ifndef bool +typedef unsigned char bool; +#endif +#ifndef FALSE +# define FALSE 0 +#endif +#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/include/str_array.h b/include/str_array.h index bcefdf8..3b37fda 100644 --- a/include/str_array.h +++ b/include/str_array.h @@ -8,6 +8,8 @@ #ifndef TOKEN_H #define TOKEN_H +#include "r3_define.h" + typedef struct _str_array { char **tokens; int len; diff --git a/src/node.c b/src/node.c index 20a701c..38b9fcf 100644 --- a/src/node.c +++ b/src/node.c @@ -14,6 +14,7 @@ // #include #include "r3.h" +#include "r3_define.h" #include "r3_str.h" #include "str_array.h"