delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/07/22/16:28:45

Date: Sat, 22 Jul 2000 16:29:42 -0400
From: Phil Edwards <pedwards AT disaster DOT jaj DOT com>
Message-Id: <200007222029.QAA29095@disaster.jaj.com>
To: law AT cygnus DOT com
Subject: Re: GCC headers and DJGPP port
Cc: djgpp-workers AT delorie DOT com, eliz AT is DOT elta DOT co DOT il, gcc AT gcc DOT gnu DOT org,
martin AT loewis DOT home DOT cs DOT tu-berlin DOT de, mrs AT windriver DOT com
Reply-To: djgpp-workers AT delorie DOT com

Jeffrey A Law <law AT cygnus DOT com>:
> Let's take the __null issue again.  According to the C++ standard it is
> an implementation-defined C++ null pointer constant -- it also states
> that (void *)0 is not an acceptable value.
>
> It turns out that using "0" doesn't work, nor does "0L" for reasons I
> can't remember.

Overloading based on the distinction between pointer and integer becomes
impossible, or a freakish nightmare at best.  If you pass in "NULL",
you'd expect the compiler to choose the pointer version, but if it's 0 a
compiler will -- quite correctly -- choose the integer version.

With 0L you can at least hope to get an ambiguity warning.  Sometimes.
Except if the overloaded function takes a long integer, then you're
screwed again.

Having __null magically only match pointer types is an extremely froody
solution, and I'm glad that g++ went that route.


Phil

- Raw text -


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