From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HTML_MESSAGE,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2214 invoked from network); 21 Sep 2020 00:01:34 -0000 Received: from minnie.tuhs.org (45.79.103.53) by inbox.vuxu.org with ESMTPUTF8; 21 Sep 2020 00:01:34 -0000 Received: by minnie.tuhs.org (Postfix, from userid 112) id 3C1A19CBD2; Mon, 21 Sep 2020 10:01:34 +1000 (AEST) Received: from minnie.tuhs.org (localhost [127.0.0.1]) by minnie.tuhs.org (Postfix) with ESMTP id C77F79C772; Mon, 21 Sep 2020 10:00:55 +1000 (AEST) Authentication-Results: minnie.tuhs.org; dkim=pass (1024-bit key; unprotected) header.d=ccc.com header.i=@ccc.com header.b="OEv1ibJz"; dkim-atps=neutral Received: by minnie.tuhs.org (Postfix, from userid 112) id DAE8994483; Mon, 21 Sep 2020 10:00:52 +1000 (AEST) Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by minnie.tuhs.org (Postfix) with ESMTPS id 703C2940FD for ; Mon, 21 Sep 2020 10:00:51 +1000 (AEST) Received: by mail-qk1-f172.google.com with SMTP id c62so95630qke.1 for ; Sun, 20 Sep 2020 17:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ccc.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5Hn5j0hyLwqo65l1hs7JIIaqPav6F5EGKWD5nrWPo60=; b=OEv1ibJzaaI2Osjwotv0XO3YvJEywMekotsdTogGcCddyyv24HCZnIVzmtj062eFyG U0ncQtbDS9Ktr9p1CnnvF7I/hynEGQVaH3uYlcSbnXolhKbTSerg/z8qz4AeP+HgeGRv MI/xh+SLkBwBoWqnSUKzjIxpg2oMuKxxqfNjw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5Hn5j0hyLwqo65l1hs7JIIaqPav6F5EGKWD5nrWPo60=; b=D/hMC31lwNa6JblJ+VNSuqGt4Cih4sV2QSENgPhqJHEgeyvG3RTLAH9cr8yV+eGV0N Q3oDVF9Yw4lKaHvuPAl8lkipHq4eXUq5HQzenmNmMag/wKjbyRq2+LzwWxyPXxXJ0vr7 AZr7o6sbCEq522LK1YuOkGsKhnevs152S5dyx8US/cy6l/t2vuNiXcizkokUJwX7Di2J wzhxnR5Y4GOIlBF2gOgkhK1cUCvW0xh5ZeJt2DTfK8riHJ2O3guSfaD0Bp1YBIs0ok6G jI9hZMVNGU/msxDmhodAmji2BcnFxqep/Ox/u4OSFLHcAmAsZfI0t2XC63GgvosSxYJ+ jBjg== X-Gm-Message-State: AOAM533hZ5r8Kd5Jcy+DcH9IJ1wM1Y7m8dWbB2negYvTH1XDVFwFu0oR h5uUl9G6n+j8YEw4zmEIDxhOArs5gfi05dWPdwXskQ== X-Google-Smtp-Source: ABdhPJxYfNvN/nSty1OhYO+7xQ0gYoqXLT6Fepcjv0B8+FIJrzPDHLKhbSaiR9Jx1t3jyV6vf4q7SXnd9dMc5mrCjtk= X-Received: by 2002:a37:7ac1:: with SMTP id v184mr2305341qkc.146.1600646449895; Sun, 20 Sep 2020 17:00:49 -0700 (PDT) MIME-Version: 1.0 References: <20200920230057.C5D1A4422E@lignose.oclsc.org> In-Reply-To: From: Clem Cole Date: Sun, 20 Sep 2020 20:00:38 -0400 Message-ID: To: Norman Wilson Content-Type: multipart/alternative; boundary="0000000000000ed52405afc78bcf" Subject: Re: [TUHS] reviving a bit of WWB X-BeenThere: tuhs@minnie.tuhs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: The Unix Heritage Society mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tuhs@tuhs.org Errors-To: tuhs-bounces@minnie.tuhs.org Sender: "TUHS" --0000000000000ed52405afc78bcf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I was also stating (under Henry=E2=80=99s 10th) using a properly defined ma= cro with the complete cast scheme will be correct and portable to all known conforming C compilers no matter the target HW architecture =E2=80=94 which= in a commercial SW setting is highly valued. Clem On Sun, Sep 20, 2020 at 7:53 PM Clem Cole wrote: > Norman NULL has to be defined and I said that/showed it. The standard > says where. I was not trying to compile NULL without a definition which = I > agree it not legal. If that is what Doug was implying I missed understoo= d > him but I note NULL was introduced in Typesetter C /V7 where those compil= er > s set it to 0 in studio but the ANSI/ISO moved it. > > On Sun, Sep 20, 2020 at 7:03 PM Norman Wilson wrote: > >> Doug McIlroy: >> >> >> >> To put it more strongly. this is not a legal C source file. >> >> char *s =3D NULL; >> >> But this is. >> >> char *s =3D 0; >> >> >> >> Clem Cole: >> >> >> >> 67)The macro NULL is defined in (and other headers) as a >> null >> >> pointer constant; see 7.19. >> >> >> >> =3D=3D=3D=3D >> >> >> >> $ cat null.c >> >> char *s =3D NULL; >> >> $ cat zero.c >> >> char *s =3D 0; >> >> $ >> >> >> >> zero.c is a legal C program. null.c is not. Create >> >> files exactly as shown and compile them if you don't >> >> believe me. >> >> >> >> Prepend `#include ' (or or ) >> >> to null.c and it becomes legal, but I think that's Doug's >> >> point: you need an include file. >> >> >> >> Personally I prefer to use NULL instead of 0 when spelling >> >> out a null pointer, because I think it's clearer: >> >> if ((buf =3D malloc(SIZE)) =3D=3D NULL) >> >> error("dammit andrew"); >> >> though I am willing to omit it when there's no confusion >> >> about =3D vs =3D=3D: >> >> if (*p) >> >> dammit(*p, "andrew"); >> >> >> >> But that's just a question of style, and Doug's is fine too. >> >> >> >> The language does not require the compiler to pre-define >> >> NULL or to recognize it as a keyword; you have to include >> >> an appropriate standard header file. >> >> >> >> Norman Wilson >> >> Toronto ON (not 0N nor NULLN) >> >> -- > Sent from a handheld expect more typos than usual > > > -- Sent from a handheld expect more typos than usual --0000000000000ed52405afc78bcf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I was also stating (under Henry=E2=80=99s 10th) using a p= roperly defined macro with the complete cast scheme will be correct and por= table to all known conforming C compilers no matter the target HW architect= ure =E2=80=94 which in a commercial SW setting is highly valued.

Clem

On Sun, Sep 20, 2020 at 7= :53 PM Clem Cole <clemc@ccc.com>= wrote:
Norman NU= LL has to be defined and I said that/showed it. =C2=A0 The standard says wh= ere.=C2=A0 I was not trying to compile NULL without a definition which I ag= ree it not legal.=C2=A0 If that is what Doug was implying I missed understo= od him but I note NULL was introduced in Typesetter C /V7 where those compi= ler s set it to 0 in studio but the ANSI/ISO moved it.=C2=A0

=
On Sun, Se= p 20, 2020 at 7:03 PM Norman Wilson <norman@oclsc.org> wrote:
Doug McIlroy:



=C2=A0 To put it more strongly= . this is not a legal C source file.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 char *s =3D NULL;

=C2=A0 But this is.

=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 char *s =3D 0;



Clem Cole:



= =C2=A0 =C2=A067)The macro NULL is defined in <stddef.h> (and other he= aders) as a null

=C2=A0 =C2=A0pointer constant; see 7.19.


=3D=3D=3D=3D



$ cat null.c

char *s =3D NULL;
<= br>$ cat zero.c

char *s =3D 0;

$



zero.c is a l= egal C program.=C2=A0 null.c is not.=C2=A0 Create

files exactly as s= hown and compile them if you don't

believe me.



Pr= epend `#include <stddef.h>' (or <stdlib.h> or <stdio.h&g= t;)

to null.c and it becomes legal, but I think that's Doug'= s

point: you need an include file.



Personally I prefe= r to use NULL instead of 0 when spelling

out a null pointer, because= I think it's clearer:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 if ((buf =3D = malloc(SIZE)) =3D=3D NULL)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 error("dammit andrew");

though I am willing= to omit it when there's no confusion

about =3D vs =3D=3D:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (*p)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 dammit(*p, "andrew");



= But that's just a question of style, and Doug's is fine too.


The language does not require the compiler to pre-define

NU= LL or to recognize it as a keyword; you have to include

an appropria= te standard header file.



Norman Wilson

Toronto ON (no= t 0N nor NULLN)

--
Sent from a handheld expect more typos than= usual


--
Sent from a handhel= d expect more typos than usual
--0000000000000ed52405afc78bcf--