NULL v. zero
Posted Jul 15, 2004 17:03 UTC (Thu) by
kamil (subscriber, #3802)
In reply to:
NULL v. zero by ikm
Parent article:
NULL v. zero
0 is not good enough if the compiler can't guess from the context that you want a pointer. This typically happens in cases such as this one:
int execl(const char *path, const char *arg, ...);
Here, one should pass null pointer as the last argument. Passing 0 is usually OK on 32-bit machines, but not on 64-bit ones. You must explicitly cast 0 to a pointer type to conform to the standard. But NULL will be just as erroneous here, given that the standard allows it to be defined as a plain int 0. So you would in fact have to write (void*)NULL to conform both to the C standard and to Linus :-).
(
Log in to post comments)