Parameterized macros
int square(int x) {
return x * x;
}
The macro rewrites the above code as follows:
#define square(x) ( (x) \* (x) )
No spaces are allowed between the macro name and the opening parenthesis
#include <stdio.h>
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
int main(void) {
printf("Max between 20 and 10 is %d\n", MAX(10, 20));
return 0;
}
Comments