软件项目工程中的调试技巧

来源:互联网 发布:过程关系矩阵图 编辑:程序博客网 时间:2024/05/16 14:06

#define FUN_DEBUG 0

#define ARG_DEBUG 0

#define ERR_DEBUG 0


#if FUN_DEBUG

    #define FUN_IN(fmt, args...)  printf("====>%s()"fmt"\n",  __func__,  ##args)

    #define FUN_OUT(fmt args...)   printf("<====%s()"fmt"\n",  __func__, ##args)

#else

    #define FUN_IN(fmt, args...)

    #define FUN_OUT(fmt args...)

#endif


/**********************************/

或者:

#if FUN_DEBUG

    #define FUN_IN(fmt, ...)  printf("====>%s()"fmt"\n",  __func__,  ##__VA_AGRS__)

    #define FUN_OUT(fmt, ...)   printf("<====%s()"fmt"\n",  __func__, ##__VA_AGRS__)

#else

    #define FUN_IN(fmt, ...)

    #define FUN_OUT(fmt, ...)

#endif


/**********************************/


#if ARG_DEBUG

    #define PRINT_ARG(fmt, args...)  printf("%s()"fmt"\n",  __func__, ##args)

#else

#define PRINT_ARG(fmt, args...)

#endif


#if ERR_DEBUG

    #define PRINT_ERR(fmt, args...)  \

    do \

    { \

    printf("\033[5;41;32m [ERROR] ---> %s():line[%d]:\033[0m\n", __func__, __LINE__); \

    printf(" "fmt, ##args); \

    }while(0)

#else

#define PRINT_ERR(fmt, args...)            

#endif



Note: #if 和 #ifdef 的区别

#if 是判断表达式是否为真来决定编译哪一个部分, #ifdef是主要参数被#define定义过 则编译下面代码。

0 0
原创粉丝点击