Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ecr.UUCP Path: utzoo!hcrvax!ecrhub!ecr!peterc From: peterc@ecr.UUCP (Peter Curran) Newsgroups: net.lang.c Subject: Re: SIZEOF Message-ID: <347@ecr.UUCP> Date: Tue, 22-Jan-85 10:54:17 EST Article-I.D.: ecr.347 Posted: Tue Jan 22 10:54:17 1985 Date-Received: Thu, 24-Jan-85 04:24:45 EST Organization: Emerald City Research, Toronto Lines: 21 Of course, C SHOULD be defined to allow sizeof(int) != sizeof(int *). However, due to one point in the Reference Manual, and K&R (and, I assume, the standard, although I haven't checked), they are actually required to be equal. The problem is that "0" is defined to be the Null pointer constant. When "0" is passed as a parameter to a function, the compiler cannot tell whether an int or an int * is intended. The effect of this is that sizeof(int) must equal sizeof(int *), and even more, the value of the Null address constant must be bit-for-bit identical to the value of ((int) 0). Of course, many compilers do not conform to this requirement. The problem can be avoided by, for example, always using (say) NULL as the Null address constant, where NULL is #defined as something like ((char *) 0). Doing so conforms to the Reference Manual, but not doing so also conforms (and of course many, if not most, C programs don't follow this practice). The real solution, of course, would be to introduce a new keyword, say "null", which represents the Null address constant, with an implementation- defined value. However, I doubt that that will ever come about. Anyone who has made much effort at porting C code has no doubt encountered this problem, but I don't think it is as well known as it should be.