[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 0 vs. NULL
From: |
Micah Cowan |
Subject: |
Re: 0 vs. NULL |
Date: |
Sat, 13 Oct 2007 17:50:38 -0700 |
User-agent: |
Thunderbird 1.5.0.13 (X11/20070824) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Bruno Haible wrote:
> Ben Pfaff wrote:
>> ISO C says that NULL can be defined as 0, without a cast to void
>> *, and it is always defined that way in C++.
>
> The latter statement is not true. ISO C++ 18.1.(3) says:
>
> "The macro NULL is an implementation-defined C++ null pointer constant
> in this International Standard (4.10)."
> with footnote:
> "Possible definitions include 0 and 0L, but not (void*)0."
>
> and g++ defines NULL to __null. The differences between NULL and 0 in g++
> are least:
> - sizeof (NULL) == sizeof (void*),
> - sin (NULL) gives a warning, sin (0) does not.
So it could be something besides 0 or 0L. But I'm pretty sure Ben's
point was that it is not safe to assume that using NULL, addresses those
argument-passing problems, as you claimed (that is, it may be defined as
just 0 or another type that is not compatible with (void*)). To be
portable, it must be cast when passed as a vararg param.
- --
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHEWfe7M8hyUobTrERCAKVAKCKw1ES8cc4hLKbBBrV0VThXc3qVgCfRlbl
udvr5wlLCmtfV+7TNgO6Ans=
=wg6o
-----END PGP SIGNATURE-----
- Test for getaddrinfo() broken on Tru64 UNIX 5.1, Albert Chin, 2007/10/10
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Bruno Haible, 2007/10/13
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Benoit SIGOURE, 2007/10/13
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Ben Pfaff, 2007/10/13
- Re: 0 vs. NULL (was: Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1), Bruno Haible, 2007/10/13
- Re: 0 vs. NULL,
Micah Cowan <=
- Re: 0 vs. NULL, Bruno Haible, 2007/10/13
- Re: 0 vs. NULL, Paul Eggert, 2007/10/15
- Re: 0 vs. NULL, Micah Cowan, 2007/10/15
- Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Jim Meyering, 2007/10/13
Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Simon Josefsson, 2007/10/13
Re: Test for getaddrinfo() broken on Tru64 UNIX 5.1, Albert Chin, 2007/10/14