特殊的宏定义
#define exp(s) #s
#define STR_TO_CAT(a, b) a##b
#define CON1(a, b) a##e##b
#define CON2(a, b) a##b##00
日志的打印等级
#ifndef _DEBUG_H
#define _DEBUG_H
#include <stdio.h>
#define PRINTF_LEVEL 0
#if (PRINTF_LEVEL == 0)
#define LOG(...) printf("COMMON_DEBUG ======= :"__VA_ARGS__)
#define LOG_ERROR(err_msg) \
do { \
printf("COMMON_DEBUG_ERROR=======: %s:%s:%d", __FILE__, __FUNCTION__, __LINE__); \
printf(" (err_msg:%s)\n", err_msg);
} while(0) \
#elif (PRINTF_LEVEL == 1)
#define LOG(...) printf(__VA_ARGS__)
#define LOG_ERROR(err_msg) \
do { \
printf("ERROR=======: %s:%s:%d", __FILE__, __FUNCTION__, __LINE__); \
printf(" (err_msg:%s)\n", err_msg);
} while(0) \
#else
#define LOG(...) do {} while(0)
#define LOG_ERROR(err_msg) do {} while(0)
#endif
#endif
|