Mail Archives: djgpp-workers/2000/07/22/16:28:45
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 -