#define SWAP(a,b) { a^=b ; b^=a ; a^=b; }
if (x < 0)
         SWAP(x,y);
else
         SWAP(y,x);    
My code given above doesn't work. It gives the following error while compiling.
trial.c:3:1: error: expected identifier or '(' before 'if'
trial.c:5:1: error: expected identifier or '(' before 'else'
I am trying to figure out the exact reason why it is not working. The preprocessor expands the macro as follows
if (x < 0)
         { 
           x^=y ; 
           y^=x ; 
           x^=y ; 
         }; 
else
         { 
           y^=x ; 
           x^=y ; 
           y^=x ; 
         };
I have a suspicion that the semi-colon at the end of curly braces is causing the problem. But I am not sure. Can someone explain?
 
     
     
     
     
    