1. printf的宏定义
#define XXX_ERROR 0
#define XXX_WARNING 1
#define XXX_INFO 2
#define XXX_DEBUG 3
#define XXX_NONE 0xFF
#define XXX_DEBUG_LEVEL XXX_DEBUG
#if (XXX_DEBUG_LEVEL >= XXX_NONE)
#define xxx_printf(level, fmt, arg...)
#else
#define xxx_printf(level, fmt, arg...)
do {
if (level <= XXX_DEBUG_LEVEL) {
switch(level)
{
case XXX_ERROR :
printf("
[Error] "fmt, ##arg);
break;
case XXX_WARNING :
printf("
[Warning] "fmt, ##arg);
break;
case XXX_INFO :
printf("
[Info] "fmt, ##arg);
break;
case XXX_DEBUG :
printf("
[Debug] "fmt, ##arg);
break;
default :
printf("
[Level] "fmt, ##arg);
break;
}
}
}while(0)
#endif