1. 程式人生 > >除錯技巧:封裝printf列印除錯資訊和巨集定義開關

除錯技巧:封裝printf列印除錯資訊和巨集定義開關

/* #define DEBUG */

#ifdef DEBUG
    #define DEBUG_ERR(format, ...) \
    do{ \
        printf("\r\n"); \
        printf("FILE: "__FILE__", LINE: %05d: "format,__LINE__,##__VA_ARGS__); \
        printf("\r\n"); \
    } while (0)
#else
    #define DEBUG_ERR(format, ...)
#endif