Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: comp.lang.c Subject: Re: To comment 48: Xenix Message-ID: <17441@sun.uucp> Date: Mon, 27-Apr-87 14:45:22 EDT Article-I.D.: sun.17441 Posted: Mon Apr 27 14:45:22 1987 Date-Received: Wed, 29-Apr-87 00:48:13 EDT References: <77200001@uiucdcsp> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 52 >But I think that declaring: > >#define NULL (char *)0 > >is expensive but will always do the trick for all models (small,large,huge) And will also tick "lint" (and PCC, in some cases, I suspect) with some justification. >On UNIX System V AT I had done the typical tricks in C of: > > if (!charptr) > > Even though I new it was crypt, but efficient. If if (!charptr) is any more efficient than if (charptr == 0) you have some justification for flaming the author(s) of your compiler. The two constructs are equivalent, and any good compiler will produce equally efficient code for them. > So after alot of frustration I figured out that NULL was defined > as 0L. Which makes sense since we need a 32 bit zero value, which > is not an integer. No, it makes no sense whatsoever because: 1) a 32-bit zero value *is* an integer; it just doesn't happen to be an "int"; and 2) "we" don't need a 32-bit zero value, we need a null pointer of the appropriate type, and null pointers are not integers. > But As for people saying that if (charptr == 0) should work, > "for any good C programmer's" I think thats hogwash. Anyone who knows the C language well enough to make their comments on this newsgroup worth believing knows that if (charptr == 0) should work. Anyone who knows the C language well enough that they should feel competent to implement it knows that it should work.