Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!henry
From: henry@utzoo.UUCP (Henry Spencer)
Newsgroups: net.lang.c
Subject: Re: if (p), where p is a pointer - PLEASE READ
Message-ID: <5980@utzoo.UUCP>
Date: Wed, 18-Sep-85 13:00:27 EDT
Article-I.D.: utzoo.5980
Posted: Wed Sep 18 13:00:27 1985
Date-Received: Wed, 18-Sep-85 13:00:27 EDT
References: <118@mit-hector.UUCP> <2792@sun.uucp> <693@sfmag.UUCP> <2798@sun.uucp>, <701@sfmag.UUCP>
Organization: U of Toronto Zoology
Lines: 18

> Well, now we come to the can of worms which causes some implementations to
> #define NULL (char *) 0: machines where pointers occupy more space than ints.
> In these implementations, foo(NULL) is absolutely incorrect (duplicate paren'd
> comment from previous paragraph) (and try porting "typical" code to such
> machines; but I digress).
> 
> ...  The solution may be that NULL should be 0L (but what
> about the venerable old PDP-11?  In that case, foo(NULL) passes too much stuff
> on the stack.  So, what is *the* answer?)....

*The* answer is that foo(NULL) is absolutely incorrect on any machine.
The proper way to write this is foo((char *)NULL).  The only portable way
to get something that looks like a NULL pointer of the proper type onto
the stack, is to put a NULL pointer of the proper type onto the stack
explicitly.  There are no shortcuts on this one.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry