C语言:预定义,设置打印调试函数

#include <stdio.h>                                                                                   
#include <string.h>

#define pri(fmt, ...) 	printf(" ---  "__FILE__"  --- %s --- %d :" ,__FUNCTION__,__LINE__ );\
						printf(fmt, ##__VA_ARGS__);\
						printf("\n")

#define pri_mark() 	printf(" ____________ %s --- %s --- %d ! \n" ,__FILE__,__FUNCTION__,__LINE__ )

int main()
{
	int i = 45;
	int a = 23;
	
	pri("%d",i);
	
	pri_mark();
	
	pri(" a : %d, i : %d ", a, i);
       
	return 0;
	
}

运行结果:

 ---  test.c  --- main --- 22 : 45
 ____________ test.c --- main --- 24 ! 
 ---  test.c  --- main --- 26 :  a : 23, i : 45 

参考链接:
https://blog.csdn.net/weixin_42167759/article/details/81138469

猜你喜欢

转载自blog.csdn.net/weixin_38184741/article/details/84960487