Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site kobold.UUCP
Path: utzoo!watmath!clyde!floyd!harpo!decvax!genrad!grkermit!masscomp!kobold!tjt
From: tjt@kobold.UUCP
Newsgroups: net.lang.c
Subject: Re: Is #define NULL 0L ok?
Message-ID: <281@kobold.UUCP>
Date: Mon, 12-Mar-84 12:26:16 EST
Article-I.D.: kobold.281
Posted: Mon Mar 12 12:26:16 1984
Date-Received: Wed, 14-Mar-84 07:08:27 EST
References: <4072@edai.UUCP> <2393@brl-vgr.ARPA>
Organization: Masscomp, Westford, MA
Lines: 20

Using:

	#include 
	#undef	NULL
	#define	NULL 0L

will fail on a machine with 16 bit pointers, 16 bit int's but 32-bit
longs (the pdp-11, for example).  On the pdp-11, defining NULL as 0L
will cause two words to be pushed on the stack for as a function
argument while the called routine will only be expecting one word for
that argument.

As has been pointed out too many times to count, it is impossible to
define a generic null pointer in C: you have to cast 0 to the pointer
type when passing it as an argument.  You can do this by including the
type cast in each use, or #define a null pointer for each pointer type
you use.
-- 
	Tom Teixeira,  Massachusetts Computer Corporation.  Westford MA
	...!{ihnp4,harpo,decvax}!masscomp!tjt   (617) 692-6200 x275