Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Feb 1997 19:44:22 -0500 (EST)
From:      Thomas David Rivers <ponds!rivers@dg-rtp.dg.com>
To:        ponds!dimaga.com!eivind, ponds!lambert.org!terry
Cc:        ponds!freebsd.org!hackers, ponds!uriah.heep.sax.de!joerg_wunsch
Subject:   Re: NULL as ((void*)0) (was Re: strlen() question)
Message-ID:  <199702150044.TAA12014@lakes.water.net>

next in thread | raw e-mail | index | archive | help
> 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
> 
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199702150044.TAA12014>