I'm trying to create macro in c which purpose is re-write in reverse order the bits of each cell in array, for example, if cell A[1] is: 1100, the final cell A[1] will be: 0011.
I have created the macro but I have compilation issue. Please let me know were I got wrong (I'm sure it can be look more compact but I wont to know what I'm missing).
#include <stdio.h>
#define REVERSE(array, type) \
( \
type * p; \
unsigned (type)=mask1, mask2, test;\
mask1=1;\
mask2=mask1<<(sizeof(type)-1);\
for(p=(array);p ;p=p+1){\
while((mask1=<<1)<(mask2=>>1)){\
if(((*p)&mask1)!=((*p)&mask2)){\
if((*p)&mask1==0){\
*p=*p|mask1;\
*p=*p^mask2;\
}else{\
*p=*p^mask1;\
*p=*p|mask2;\
}\
}\
} \
)
int main(){
int i;
int array[]= {1,2,3,4,5};
REVERSE((array), int);
for(i=1; i<5; i++)
printf(" \'%d\' ", array[i]);
return(0);
}