C语言的debug宏

在ç语言中添加调试宏定义,当我们需要调试时将其打开,不需要使用时将其关闭,非常方便我们调试

下面是这个宏定义

#include <stdio.h>

#ifdef DEBUG

    #define debug(...) \
        do {    \
            fprintf(stderr, "%s %s [%d]: ", __FILE__, __FUNCTION__, __LINE__);  \
            fprintf(stderr, __VA_ARGS__);   \
        } while(0)
#else
    #define debug(...)
#endif

猜你喜欢

转载自blog.csdn.net/weixin_42462202/article/details/84891477
今日推荐