Mail Archives: djgpp/1996/01/15/12:30:45
On Sun, 14 Jan 1996, Erik Max Francis wrote:
> Eli Zaretskii wrote:
>
> > Yes, it *is* better. ANSI C says that the null pointer (for any type) is
> > a zero cast to a pointer to that type, but it doesn't guarantee that the
> > bit pattern for the null pointer is all-zero (so that !null_ptr is
> > true). So you could write `if (my_pointer == 0)' (because the compiler
> > automatically will cast 0 to the pointer type), but `if (!my_pointer)'
> > may not work on some odd architectures.
>
> Are you sure this is the case? I was under the impression that (!p) was exactly
> as equivalent as (p == 0) in the context where p is a pointer.
You were right, I was wrong: it *is* the same. It's just a matter of
style, not standards. Sorry to cause confusion.
- Raw text -