backslash and newline separated by space [enabled by default]的解决:
宏定义的续行符 小心\后面不要有space
#include<stdio.h>
//宏定义的续行 小心\后面不要有space
#define MAX(type)\
type max(type a,type b){ \
type ret; \
if(a>b) { \
ret=a; \
} \
else { \
ret=b; \
} \
}
MAX(int)
int main()
{
int x;
x=max(10,90);
printf("x=%d",x);
return 0;
}
对经常使用的函数定义为宏有好处:
对已经编译的c源程序,在cmd中转的该源程序文件路径,然后
gcc -E UseDefine.c1 -o UseDefine1.c2 回车
type UseDefine1.c 回车
看看他的预编译,第三行多了一个函数。想必你已经知道了,宏的替换作用。
如果改成MAX(float)
那么你懂得,float将代替int的位置。