This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ definition of NULL


Jason Merrill wrote:

> Chad, please try compiling with -ansi.  In 1.1, when -ansi is on, __null is
> of integral type.

This breaks all kinds of code, and removes internal defines that the code
depends on to determine the platform I am on.


Martin Knoblauch wrote:

>  Hmm. Are you now assuming that sizeof(long) == sizeof(void *)?
> What if the IA64 Unixes come out as LL-P-64, leaving "long" at
> 32 bit to make porting M$ legacy software easier? While it is
> a hassle in the short term, explicitely casting will make things
> easier in the long run.

The code is assuming this, unfortunately.  But it has been common practice (and
I believe it will remain) that long is the size of a pointer.  The code is
already ported to 8 platforms (including 64-bit), and this hasn't been an
issue.


Thomas Kunert wrote:

> Since NULL is a constant casting it is rather dumb. Your usage of that
> constant is not intended by the standard and hence misguiding. Instead
> of casting I'd replace any `NULL' with `0'. This is easily done using
> something like sed. Then your code will compile and becomes more
> readable.

As I have said before, this is existing code (not mine), and even though it is
not so "proper" (which I agree), it should still work if NULL is defined as the
standard suggests.


"Martin v. Loewis" wrote:

> Yes, it looks like this is a bug in egcs 1.1.1. I haven't checked
> whether the bug is still present in 1.1.2, however, it appears it is
> fixed in the current development snapshots (egcs-2.93.10).

This has been pointed out to me, and I am glat to hear this.  Do we have any
idea when it would make it into a regular release?  The following version
(1.1.3 or 1.2 (which ever comes first))?

> From that, it appears you have a number of options:
>
> a) Replace all occurences of NULL with 0. This is IMHO the Right Thing
>    (tm), because the NULL symbol is an ugly hack, and just there for
>    backwards compatibility.
>
> b) Use a more current egcs release. You've indicated that you need
>    production quality, so this is probably not an option.
>
> c) Change your installation of egcs to define NULL in whatever way you
>    think is appropriate.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]