libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More NULL fixups for ltdl.c on branch1-4


From: Gary V . Vaughan
Subject: Re: More NULL fixups for ltdl.c on branch1-4
Date: Tue, 15 Oct 2002 15:18:28 +0100

Thanks Bob,

I remembered that my coding style incorporated the use of explicit zeros rather than relying on the vagaries of NULL definitions for some portability reason, but I didn't recall the specifics. I don't want to revert to using NULL's for the reasons set out below. Once I've got CVS working on my new machine I'll back out Albert's one liner too.

Cheers,
        Gary.

On Monday, October 14, 2002, at 06:59 PM, 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.comgroups?hl=en&lr=&ie=UTF8&th=e21413d0f4430dc2&seekm=19 92May6.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'?

Bob
--
  ())_. Gary V. Vaughan     gary@(oranda.demon.co.uk|gnu.org)
( '/ Research Scientist http://www.oranda.demon.co.uk ,_())____ / )= GNU Hacker http://www.gnu.org/software/libtool \' `& `(_~)_ Tech' Author http://sources.redhat.com/autobook =`---d__/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]