delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/03/25/10:51:16

Message-Id: <m0yHoqi-000S2qC@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>,
Peter Palotas <blizzar AT hem1 DOT passagen DOT se>, djgpp AT delorie DOT com,
djgpp-workers AT delorie DOT com
Date: Wed, 25 Mar 1998 09:03:06 +0000
MIME-Version: 1.0
Subject: Re: NULL redefined! :(
References: <m0yHSrw-000S2qC AT inti DOT gov DOT ar>
In-reply-to: <Pine.SUN.3.91.980324171958.22871J-100000@is>

Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:

> On Tue, 24 Mar 1998, Salvador Eduardo Tropea (SET) wrote:
> 
> > But perhaps we must investigate if the __null have some advantage and:
> > 
> > 1) Define NULL conditionally (no redefinition)
> > 2) If not defined:
> > a) Test the gcc version, if 2.8.0 define with __null
> > b) if prior define with 0.
> 
> I think that the C header(s) which define NULL should do so only under 
> "#ifndef __cplusplus".  It is safer to let C++ use its own definition 
> throughout, and leave C at its usual definition.
> 
> The only thing that bothers me is the case of a C++ code that calls a C 
> function and passes it NULL as one of its arguments.  Can somebody check 
> what does the C function see in that case, and will it compare equal to 
> the C's notion of NULL?

I did some experiments last night (I didn't have enough time to create patchs) 
and here are what I found:

1) __null exists only in C++ so __cplusplus is needed.
2) Is equivalent to 0, that's:

a) char *foo=0; then (foo==0) is true.
b) passing foo to a C module and making (foo==0) in the C code works OK.

I didn't have the time to check what advantage have __null, but I think is 
related with some C++ standard or with some stronger syntax check.

SET
------------------------------------ 0 --------------------------------
Visit my home page: http://set-soft.home.ml.org/
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
CQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(541) 759 0013

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019