Specific pointer -> generic pointer -> boolean (i.e. implicit compare to 0) seems not to work as expected.
void main() { char* p; char* q; char xdata* xp = NULL; bit fail = FALSE; // This fails. if ( p = xp ) { fail = TRUE; } // This is ok. if ( ( q = xp ) == NULL ) { fail = TRUE; } }
This will strip out the memory types on both sides and then a valid comparison can be made. What do you think? I'd probably do something like this:
#define ISNULL(x) (((unsigned) (void *) (x)) == 0) void * p; // gerneric pointer . . . if (ISNULL(p)) { // NULL pointer detected }