一个打印调试信息的样例
作者:刘昊昱
博客:http://blog.csdn.net/liuhaoyutz
#include <stdio.h> #define HAOYU_DEBUG_TYPE #ifdef HAOYU_DEBUG_TYPE #define HAOYU_DEBUG(...) \ do { \ printf("\n[HAOYU_DEBUG] ------------------ in %s:%d %s()------------------\n", __FILE__, __LINE__, __FUNCTION__); \ printf(__VA_ARGS__);\ printf("\n\n"); \ } while(0); #else #define HAOYU_DEBUG(...) do {} while(0) #endif int main(int argc, char **argv) { int i = 0; printf("hellodebug!\n"); HAOYU_DEBUG("debug message, i = %d", i); return 0; }