Is "if (!pointer)" as portable as "if (pointer == NULL)" ???
Henry Spencer
henry at utzoo.uucp
Thu May 3 02:46:47 AEST 1990
In article <7180 at ncar.ucar.edu> steve at groucho.ucar.edu (Steve Emmerson) writes:
>Doesn't the standard guarantee that there exists an implementation-
>dependent integral type capacious enough to handle the pointer-to-
>integer-to-pointer conversion sequence and return the original pointer?
No. Indeed, the only reason why you can define NULL to be `(void *)0'
instead of just `0' or `0L' is the possibility that there may not be
an integer type large enough to match the size of a pointer. (This does
not matter to legal programs, but on many machines you can increase the
odds that a badly-written illegal program will accidentally work if you
make NULL the same size as most pointers.)
>If so, then "unsigned long" would appear to be a safe bet -- there being
>nothing longer.
Does not follow. An implementation might provide longer types.
--
If OSI is the answer, what is | Henry Spencer at U of Toronto Zoology
the question?? -Rolf Nordhagen| uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list