Re: (char *)0 vs NULL



Casper H.S. *** wrote:
"K-mart Cashier" <cdalten@xxxxxxxxx> writes:

When using functions like execle(), why do you pass (char *)0 and just
not NULL (like when calling waitpid() )? I thought (char *0) and NULL
were basically the same thing.

Because there's no prototype and NULL is a "null-pointer constant"
and not necessarily a pointer type ("0" is a valid null-pointer
constant but it would be passed as a 32 bit integer to a varargs
function like exec*)

I thought it only matters if the machine can store values of different
sizes on the stack. AFAIK, this is not the case for x86(-64), where the
stack can only be in 32 or 64-bit mode. Am I wrong, are there machines
which can store values of different sizes on the same stack?

So the C standard *requires* you to at the (char *) cast.

Or to void*, since the C standard guarantees the same binary
representation for char* and void*.

.