调试:mydbg

#ifndef _MYDBG_H_
#define _MYDBG_H_

static int dbg_switch = 0;

static inline void open_dbg(void)
{
    dbg_switch = 1;
}

static inline void close_dbg(void)
{
    dbg_switch = 0;
}

static inline int test_dbg(void)
{
    return dbg_switch;
}

/* fmt 必须是常量字符串 */
#define dbg_printf(A,fmt,...) \
do{\
    if(A && dbg_switch) {\
        printf("%s:%s:%d:" fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
    }\
}while(0)

#endif // _MYDBG_H_

 

posted @ 2012-12-29 21:43  庄庄庄  阅读(289)  评论(2编辑  收藏  举报