www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/25/07:36:16

Sender: vheyndri AT rug DOT ac DOT be
Message-Id: <3518F995.6AEA@rug.ac.be>
Date: Wed, 25 Mar 1998 13:33:25 +0100
From: Vik Heyndrickx <Vik DOT Heyndrickx AT rug DOT ac DOT be>
Mime-Version: 1.0
To: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Cc: Peter Palotas <blizzar AT hem1 DOT passagen DOT se>, djgpp AT delorie DOT com,
djgpp-workers AT delorie DOT com
Subject: Re: NULL redefined! :(
References: <m0yHSrw-000S2qC AT inti DOT gov DOT ar>

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.

Conditional redefinition is dangerous since this way NULL might get two
values that do not compare equal, even when compiled with the same
compiler version.
An unconditional #define is best (i.e. preceded with #undef) as it only
disadvantages programs which are at fault.

Checking whether gcc's version is 2.8.0, won't help a bit:
for instance the libc library can have been defined using gcc-2.7.2.1
and hence NULL would be 0. A program compiled with 2.8.0 would then
define NULL as __null. Like DJ mentionned, a library function like fopen
can return NULL (=0) and it must be possible that a program compares it
with NULL (=__null).

-- 
 \ Vik /-_-_-_-_-_-_/   
  \___/ Heyndrickx /          
   \ /-_-_-_-_-_-_/

- Raw text -


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