debug的宏定义

#ifdef DEBUG
#define ASSERT(exp)                                                     \
        do {                                                            \
          if (!(exp)) {                                                 \
            fprintf(stderr, "[ASSERT!][%s:%s:%d]: %s\n",                \
                    __FILE__, __FUNCTION__, __LINE__, #exp);            \
            abort();                                                    \
          }                                                             \
        } while (0)
#define ERROR(...)                                                      \
        {                                                               \
            fprintf(stderr, "[ERROR  ][%s:%s:%d] ",                     \
                    __FILE__, __FUNCTION__, __LINE__);                  \
            fprintf(stderr, __VA_ARGS__);                               \
        }
#define WARNING(...)                                                    \
        {                                                               \
            fprintf(stderr, "[WARNING][%s:%s:%d] ",                     \
                    __FILE__, __FUNCTION__, __LINE__);                  \
            fprintf(stderr, __VA_ARGS__);                               \
        }
#define INFO(...)                                                       \
        {                                                               \
            fprintf(stdout, "[INFO   ][%s:%s:%d] ",                     \
                    __FILE__, __FUNCTION__, __LINE__);                  \
            fprintf(stdout, __VA_ARGS__);                               \
        }
#else
#define ASSERT(exp)
#define ERROR(...)
#define WARNING(...)
#define INFO(...)
#endif

你可能感兴趣的:(debug的宏定义)