In C, I want to create such a macro function that puts the content of the first argument into the second, the content of the second into the third and the content of the third into the first. The code below does it without macro:
void circ2 ( int *a, int *b, int *c ){
int temp1;
int temp2;
int temp3;
temp1 = *a;
temp2 = *b;
temp3 = *c;
*a = temp3;
*b = temp1;
*c = temp2;
//printf( "%d\n%d\n%d\n", a, b, c );
}
int main(){
int x;
int y;
int z;
x = 1;
y = 2;
z = 3;
//circ(a, b, c);
circ(x, y, z);
printf( "%d\n%d\n%d\n", x, y, z );
return 0;
}
And the macro function that I tried to create:
#define temporary
#define temporary2
#define temporary3
#define circ(x, y, z) (x != y && x != z && y != z) ? temporary = x, temporary2 = y, temporary3 = z, y = temporary, z = temporary2, x = temporary3 : x, y, z
But I get the following error:
error: expected expression before ‘=’ token
Where am I making a mistake?