Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Is "if (!pointer)" as portable as "if (pointer == NULL)" ??? Message-ID: <1990May2.164647.6591@utzoo.uucp> Organization: U of Toronto Zoology References: <1990Apr30.222927.9548@utzoo.uucp> <7180@ncar.ucar.edu> Date: Wed, 2 May 90 16:46:47 GMT In article <7180@ncar.ucar.edu> steve@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@zoo.toronto.edu