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