调试代码插入宏

 1 #include <stdio.h>
 2 
 3 #define __DEBUG__
 4 
 5 #ifdef __DEBUG__
 6 #define DEBUG(format,...) printf("File: "__FILE__", Line: %05d: "format"
", __LINE__, ##__VA_ARGS__)
 7 #else
 8 #define DEBUG(format,...)
 9 #endif
10 
11 int main(int argc, char **argv) {
12     char str[]="Hello World";
13     DEBUG("A ha, check me: %s",str);
14     printf("File: "__FILE__", Line: %05d: A ha, check me: %s
", __LINE__, str);
15     while(1);
16     return 0;
17 }
原文地址:https://www.cnblogs.com/zhaoli/p/3656293.html