Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!linus!decvax!harpo!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: (char *)0 vs 0 vs (int *)0 Message-ID: <1731@rlgvax.UUCP> Date: Sun, 19-Feb-84 12:55:40 EST Article-I.D.: rlgvax.1731 Posted: Sun Feb 19 12:55:40 1984 Date-Received: Mon, 20-Feb-84 01:55:21 EST References: <16717@sri-arpa.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 32 > On your Honeywell Level-6 GCOS system, there are a few interesting > sizeof values: > sizeof(int) == 2 > sizeof(char *) == 6 > sizeof(parm *) == 6 > sizeof(int *) == 4 /* withing structures */ Now what size of 0 do > you want this time! It takes Lint to figure out why it dumped core on > well defined and working PDP-11 or VAX code. Bleck. Working yes, well-defined *no*. *Correct* C code would work, because the NULLs or 0s would be properly cast to (char *) or (int *) (what is parm *?). C, as a language, has no trouble dealing with machines where there are several kinds of pointers, none of which are the same size as each other or as an "int". Some *programmers* seem to have trouble with it; it has been stated several times here that the simple and correct solution is to put a cast in front of all NULL/0 values being passed as null pointers, but people continue to object that "they shouldn't have to do it", or to concoct more complicated solutions involving changing NULL to (char *)0 (which doesn't even fix programs which don't use NULL but use 0, as they are allowed to do) or adding a "null pointer" object to the language. The C Reference Manual is *very* clear on these points, and so is "lint". We have just been given an example of why there is no "generic pointer" in the C language; thanks to the author of that article for supplying a definitive reason why casts or a facility to declare the types of the arguments to a function is both necessary and sufficient. Discussion closed. OK? Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy