When trying to use a block structure as the "replacement text" with a #define statement, e.g the below,
#define swap(t,x,y) { t _z; \
_z = x; \
x = y; \
y = _z; }
Then I try to use it with:
printf( "%.2f %.2f\n", pow(a,b), pow( swap(int,a,b) ) );
But I get the following compiler error
414.c:14:21: error: expected expression before ‘{’ token
#define swap(t,x,y) { t _z; \
^
414.c:27:41: note: in expansion of macro ‘swap’
printf( "%.2f %.2f\n", pow(a,b), pow( swap(int,a,b) ) );
^~~~
Is it not permissible to use block structures like this? What if I want to use a variable local to the macro?
The problem prompt specifically says to use block structures and the "C Answer Book" has this exact piece of code as the solution.