From owner-freebsd-hackers Fri Feb 14 16:50:39 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id QAA16797 for hackers-outgoing; Fri, 14 Feb 1997 16:50:39 -0800 (PST) Received: from dg-rtp.dg.com (dg-rtp.rtp.dg.com [128.222.1.2]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id QAA16791 for ; Fri, 14 Feb 1997 16:50:36 -0800 (PST) Received: by dg-rtp.dg.com (5.4R3.10/dg-rtp-v02) id AA05493; Fri, 14 Feb 1997 19:50:04 -0500 Received: from ponds by dg-rtp.dg.com.rtp.dg.com; Fri, 14 Feb 1997 19:50 EST Received: from lakes.water.net (lakes [10.0.0.3]) by ponds.water.net (8.8.3/8.7.3) with ESMTP id TAA20097; Fri, 14 Feb 1997 19:39:41 -0500 (EST) Received: (from rivers@localhost) by lakes.water.net (8.8.3/8.6.9) id TAA12014; Fri, 14 Feb 1997 19:44:22 -0500 (EST) Date: Fri, 14 Feb 1997 19:44:22 -0500 (EST) From: Thomas David Rivers Message-Id: <199702150044.TAA12014@lakes.water.net> To: ponds!dimaga.com!eivind, ponds!lambert.org!terry Subject: Re: NULL as ((void*)0) (was Re: strlen() question) Cc: ponds!freebsd.org!hackers, ponds!uriah.heep.sax.de!joerg_wunsch Content-Type: text Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > I hereby propose changing the default declaration of NULL under FreeBSD from > #define NULL 0 > to > #define NULL ((void*)0) > for better type-safety and ease of transition to other architechtures > (e.g. Alpha). This will probably save us from a quite a few varargs-voes, > as well as generally making sure the code-base is using NULL correctly, > which is important for those reading source-code. Unfortunately, because of C++'s tighter type model; this will make valid C++ programs un-compilable. For example, you won't be able to say: char *p; if( p == NULL) in C++ (with a truly ANSI (draft) conforming C++ compiler) as void * is not convertable to a char *. But, the integer constant 0 is comparable with any pointer. The best definition for NULL is as it is, 0. Now, I was wondering just where it would save varargs problems? Can you elaborate? - Dave Rivers - > > At 03:52 PM 2/13/97 -0700, Terry Lambert wrote: > >> > > | style(9) - Kernel source file style guide > >> > > >> > See, there's the problem: libc is a user space library, not > >> > a kernel source file. > >> > >> But that wasn't what you claimed being your original problem, right? > >> I wonder when you ever admit being wrong for the first time... > > > >I said that strlen() took a NULL terminated string. I corrected > >it to 0 terminated string to make the nit-pickers happy. "NUL" > >with one "L" is the invention of a Pascal programmer with nothing > >better to do than to make noises about sign-extension on non-two's > >complement hardware for type demotion of 0 to character. > > NULL is not equvalient to null or 0 or NUL. What you're talking about is > best called a null-terminated string, as this is what it is. If you have a > Pasacal or Lisp reference handy, you can look up nil - nil in Pascal/Lisp > is the same as all uppercase NULL in C. > (I'm not doing this _only_ to pick a nit - I'm doing it because it is > somewhat that is important both for semantic understanding and for > portability.) > > > Eivind Eklund perhaps@yes.no http://maybe.yes.no/perhaps/ > eivind@freebsd.org > >