Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-unix!ctnews!pyramid!amdahl!ptsfa!ihnp4!homxb!houxm!ho95e!wcs From: wcs@ho95e.ATT.COM (Bill.Stewart) Newsgroups: news.software.b,comp.lang.c Subject: Re: News for Xenix on PC AT ? Message-ID: <1418@ho95e.ATT.COM> Date: Sat, 25-Apr-87 00:03:34 EDT Article-I.D.: ho95e.1418 Posted: Sat Apr 25 00:03:34 1987 Date-Received: Sun, 26-Apr-87 20:19:12 EDT References: <18346@ucbvax.BERKELEY.EDU> <145@sds.UUCP> <17005@sun.uucp> <146@sds.UUCP> <5787@brl-smoke.ARPA> Reply-To: wcs@ho95e.UUCP (46133-Bill.Stewart,2G218,x0705,) Organization: AT&T Bell Labs 46133, Holmdel, NJ Lines: 30 Xref: mnetor news.software.b:544 comp.lang.c:1891 In article <5787@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: :In article <146@sds.UUCP> dave@sds.UUCP (dave schmidt x194) writes: :-In article <17005@sun.uucp>, guy%gorodish@Sun.COM (Guy Harris) writes: :-> This last one falls under the heading of "stupid problems from :-> [censored] compiler writers who didn't understand C before inflicting :-> something that they claim is a C compiler on Xenix users." :[ ... much discussion by everyone about differences between :-> if (!charptr) ... /* Ugly but correct, says Doug */ :-> if (charptr == 0) ... /* Best */ :-> if (charptr == (char *)0) ... /* Almost always ok */ :- if ((int)charptr == 0) /* WRONG, of course */ :] :He, I, and others have explained more than once before in the C newsgroup :that the only fully correct definition of the macro NULL, as C now stands, :is as 0. (Under the proposed ANSI standard you could probably get away :with defining it as (void *)0.) Be careful saying this: it's only correct when you're using NULL in if (charptr == NULL) But (as Guy periodically has to remind VAX-users), you can't simply use NULL in constructs like: foo( arg1, arg2, NULL, arg4); because subroutine foo() might be expecting an argument of a different size. If you #define NULL 0, then you pass foo sizeof(int) bytes; if you #define NULL (void *)0, then you pass it sizeof(void *) bytes. If you're passing NULL (or other non-int constants), always cast to foo( arg1, arg2, (whatever_type) NULL, arg4); so the routine receives what you passed. -- # Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs