打印行号,文件名,函数名称采用的是编译器内置宏;分别为:
__FILE__ //文件名 为字符串
__LINE__ //行号 数字
__FUNCTION__ //函数名 字符串
#include <stdio.h>
#define _DEBUG_HOPE_ 3
#ifdef _DEBUG_HOPE_
#define DIM(a) (sizeof(a) / sizeof(*a)) //得到一个数组的大小
#define MALLOC(type, x) (type*)malloc(sizeof(type) * x) //申请堆空间
#define FREE(p) (free(p), p = NULL) //释放堆空间
#define LOG_INIT(i) printf("%s = %d\n", #i, i); //打印int 变量
#define LOG_CHAR(c) printf("%s = %c\n", #c, c); //打印char 变量
#define LOG_FLOAT(f) printf("%s = %f\n", #f, f); //打印float 变量
#define LOG_POINTER(p) printf("%s = %p\n", #p, p); //打印指针 变量
#define LOG_STRING(s) printf("%s = %s\n", #s, s); //打印字符串 变量
#endif
#if 0 != _DEBUG_HOPE_
#include <stdio.h>
#endif
#if 1 == _DEBUG_HOPE_
#define PRINTF_HOPE printf
#elif 2 == _DEBUG_HOPE_
#define PRINTF_HOPE(f