Re: (char *)0 vs NULL
- From: "Maxim Yegorushkin" <maxim.yegorushkin@xxxxxxxxx>
- Date: 6 Sep 2006 01:27:39 -0700
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*.
.
- Follow-Ups:
- Re: (char *)0 vs NULL
- From: Casper H . S . ***
- Re: (char *)0 vs NULL
- References:
- (char *)0 vs NULL
- From: K-mart Cashier
- Re: (char *)0 vs NULL
- From: Casper H . S . ***
- (char *)0 vs NULL
- Prev by Date: Re: (char *)0 vs NULL
- Next by Date: Re: Threads Vs Forks in Embedded Environment
- Previous by thread: Re: (char *)0 vs NULL
- Next by thread: Re: (char *)0 vs NULL
- Index(es):