To perform the XOR operations, cast the pointers to your integral type (which in C99 should be uintptr_t; in C89 unsigned long is the best you can do. Either way it's bad code).
Ideally you'd make your "nextPrev" member integral because there's absolutely no reason at all to make it a pointer. If you need it to be a pointer, though, cast back to a pointer before storing the value.
So you have something like:
Code:
struct node *next, *prev; /* you got these from the XORed value */
unsigned long next_prev;
next_prev = (unsigned long)next ^ (unsigned long)prev;
/* or if next_prev has to be a pointer */
struct node *next_prev;
next_prev = (struct node *)((unsigned long)next ^ (unsigned long)prev);
You can break it down:
Code:
unsigned long prev_int = (unsigned long)prev;
unsigned long next_int = (unsigned long)next;
unsigned long next_prev = prev_int ^ next_int;
/* etc */
Either way, the XOR linked list is an essentially worthless data structure, and you'll have no need for it in real life.