[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More NULL fixups for ltdl.c on branch1-4
From: |
Albert Chin |
Subject: |
Re: More NULL fixups for ltdl.c on branch1-4 |
Date: |
Mon, 14 Oct 2002 13:13:18 -0500 |
User-agent: |
Mutt/1.2.5i |
On Mon, Oct 14, 2002 at 12:59:21PM -0500, Bob Friesenhahn wrote:
> On Mon, 14 Oct 2002, Albert Chin wrote:
>
> > On Mon, Oct 14, 2002 at 12:15:06PM -0500, Bob Friesenhahn wrote:
> > > I believe this is a bad patch. Only 'char *' pointers may be assigned
> > > to NULL (which is of type 'char *') without an explicit cast.
> >
> > Huh?
> >
> > http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&th=e21413d0f4430dc2&seekm=1992May6.014929.21220%40leland.Stanford.EDU#link1
> >
> > I'm dealing only with C89 here. Maybe it's invalid K&R, dunno, but
> > seems ok to me.
>
> Many legacy systems were delivered with NULL defined as "(char*)0".
> That makes it a portabily problem to assign NULL to anything but a
> char* without an explicit cast.
>
> Here is some verbage from K&R's ANSI C book which indicates that
> changing from 0 to NULL should not necessary:
>
> "Pointers and integers are not interchangeable. Zero is the sole
> exception: the constant zero may be assigned to a pointer, and a
> pointer may be compared with the constant zero. The symbolic constant
> NULL is often used as a mnemonic to indicate more clearly that this is
> a special value for a pointer".
>
> Of course, this (and ANSI C) says that your updates are ok (but not
> necessary either). The original K&R says that it is valid to assign 0
> to any pointer.
>
> Why is it that you want to change the code from using '0' to 'NULL'?
Only to make it clear that we're assigning to a pointer. Yes, not
necessary. Robert can ignore if he wants, especially if there is a
chance of NULL = (char *)0 happening. If not accepted, Robert will
need to back out my previous one-line patch.
--
albert chin (address@hidden)