#define PRT(...) printf("Filename %s, Function %s, Line %d > ", __FILE__, __FUNCTION__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n");
测试代码:
#include
#include
#define PRT(...) printf("Filename %s, Function %s, Line %d > ", __FILE__, __FUNCTION__, __LINE__); \
printf(__VA_ARGS__); \
printf("\n");
int main()
{
int a =0;
PRT("a");
PRT("hello, %d ", 10);
PRT("%d, %s, %d", 10, "dafdsa", 20);
return 0;
}
测试结果:
root@ubuntu:/home/ybq/Desktop# gcc printf.c -o printf
root@ubuntu:/home/ybq/Desktop# ./printf
Filename printf.c, Function main, Line 22 > a
Filename printf.c, Function main, Line 23 > hello, 10
Filename printf.c, Function main, Line 24 > 10, dafdsa, 20