c语言宏函数怎么传递宏参数
We can define a function like Macro, in which we can pass the arguments. When a Macro is called, the Macro body expands or we can say Macro Call replaces with Macro Body.
我们可以定义一个函数,例如Macro,可以在其中传递参数。 调用宏时,宏主体会展开,或者可以说宏调用被宏主体替换 。
Now, the important thing is that: How Macro arguments evaluate? - "Macro arguments do not evaluate before Macro expansion, they evaluate after the expansion."
现在,重要的是: 宏参数如何计算? - “宏参数在宏扩展之前不评估,而在扩展之后评估。”
Consider the example:
考虑示例:
#include <stdio.h>
#define CALC(X,Y) (X*Y)
int main()
{
printf("%d\n",CALC(1+2, 3+4));
return 0;
}
Output