From xemacs-m  Sat Jun 21 14:13:41 1997
Received: from jagor.srce.hr (hniksic@jagor.srce.hr [161.53.2.130])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id OAA20050
	for <xemacs-beta@xemacs.org>; Sat, 21 Jun 1997 14:13:39 -0500 (CDT)
Received: (from hniksic@localhost)
          by jagor.srce.hr (8.8.5/8.8.4)
	  id VAA26492; Sat, 21 Jun 1997 21:13:27 +0200 (MET DST)
To: Martin Buchholz <mrb@Eng.Sun.COM>
Cc: XEmacs Developers <xemacs-beta@xemacs.org>
Subject: Re: Yet more 64bits lossage
References: <19970621012424.18989@iria.mines.u-nancy.fr> 	<199706210604.XAA07502@xemacs.eng.sun.com> 	<19970621082753.50969@iria.mines.u-nancy.fr> 	<kiglo445ua5.fsf@jagor.srce.hr> <199706211901.MAA08300@xemacs.eng.sun.com>
X-Attribution: Hrv
X-Face: Mie8:rOV<\c/~z{s.X4A{!?vY7{drJ([U]0O=W/<W*SMo/Mv:58:*_y~ki>xDi&N7XG
        KV^$k0m3Oe/)'e%3=$PCR&3ITUXH,cK>]bci&<qQ>Ff%x_>1`T(+M2Gg/fgndU%k*ft
        [(7._6e0n-V%|%'[c|q:;}td$#INd+;?!-V=c8Pqf}3J
From: Hrvoje Niksic <hniksic@srce.hr>
Date: 21 Jun 1997 21:13:26 +0200
In-Reply-To: Martin Buchholz's message of "Sat, 21 Jun 1997 12:01:50 -0700"
Message-ID: <kigu3irrcq1.fsf@jagor.srce.hr>
Lines: 46
X-Mailer: Gnus v5.4.59/XEmacs 20.3(beta7) - "Oslo"

Martin Buchholz <mrb@Eng.Sun.COM> writes:

> A definition of NULL as 0 is sufficient if application writers always
> cast NULL to pointer in an ambiguous context like varargs argument
> lists.  Almost everyone is guilty of getting this wrong, including us
> and the O'Reilly manuals (read the docs for XtVaSetValues).  The X
> docs assume that using NULL is good enough.

The X docs are wrong.  Anyway, that is solved by using

#define NULL (void *)0

> 1. sizeof(NULL) == sizeof(void *), so the natural (albeit buggy) code

OK.

> 3. The code
> 
> int foo(char*);
> foo(NULL);
> 
> compiles cleanly under C *and* C++.
> (This is why
> #define NULL ((void *)0)
> doesn't work.)

That is C++.  I was talking about ANSI C.  Anyway, it is not clear to
me why your one can pass (long)0 to a function expecting char*, but
not (void*)0.  I guess some things about C++ are better left
unanswered.  It might be instantaneously replaced by something even
more complex and less logical.  Some say it already happened.

> works on almost every system, and is a better definition for NULL.
> In particular, it's a better definition on Irix 64.

Yup.

> This kind of stuff is really tricky to get right.

It depends on the audience you target.  In ANSI C, `#define NULL 0' is 
as "right" as you can get.

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
ED WILL NOT CORRUPT YOUR PRECIOUS BODILY FLUIDS!!

