c宏定义

100 阅读1分钟

#define

宏定义采取的是直接替换
example
#define Square(format,x) printf(format,x)
Square("%d",3)	//本质printf("%d",3)

如果要多条文件就是这样的的
#define Square(format,x) printf(format,x);printf(format,x);	//用分号结束

如果出现可变参数就这样改 后面三个点可变参数,##可以省略的意思
#define Square(format,args...) fprintf(logfile,format,##args);printf(format,##args);fflush(logfile);

参考链接:www.cnblogs.com/caosiyang/a…