1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/utils.h Tue Dec 28 19:55:13 2010 +0000 1.3 @@ -0,0 +1,14 @@ 1.4 +#ifndef _H_UTILS 1.5 +#define _H_UTILS 1.6 + 1.7 +#ifndef NDEBUG 1.8 +/// Log a message to stderr 1.9 +# define LOG(x, ...) do { fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0) 1.10 +/// Log a message to stderr if 'cond' is true 1.11 +# define LOG_IF(cond, x, ...) do { if (cond) fprintf(stderr, "%s:%d:%s(): " x "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while (0) 1.12 +#else 1.13 +#define LOG(x, ...) 1.14 +#define LOG_IF(cond, x, ...) 1.15 +#endif 1.16 + 1.17 +#endif // _H_UTILS