Is it safe to assume that NULL always translates to false in C?
NULL
void *somePtr = NULL; if (!somePtr) { /* This will always be executed? */ } <
Yes (at least for any standards compliant C compiler!)
From the comp.lang.c FAQ:
Q: Is the abbreviated pointer comparison ``if(p)'' to test for non-null pointers valid? What if the internal representation for null pointers is nonzero? A: It is always valid.
Q: Is the abbreviated pointer comparison ``if(p)'' to test for non-null pointers valid? What if the internal representation for null pointers is nonzero?
A: It is always valid.