On Mon, 4 Jul 2011, Mike Stump wrote:

> On Jul 4, 2011, at 4:04 AM, Richard Guenther wrote:
> > It happens that OpenBSD suffers from a bogus fixinclude that changes
> > its perfectly valid NULL define from (void *)0 to 0.  The fix itself
> > appears to be very old and is completely bogus
> 
> I don't agree with the completely bogus part.  Why not replace it with:
> 
> #undef NULL
> #ifdef __GNUG__
> #define NULL __null
> #else   /* G++ */
> #ifndef __cplusplus
> #define NULL ((void *)0)
> #else   /* C++ */
> #define NULL 0
> #endif  /* C++ */
> #endif  /* G++ */
> 
> ?

Because I don't know how to do that?

> This is C++ friendly, C friendly and modern.  It should be very safe and 
> should work just about everywhere.
> 
> > - it replaces
> > (void *)0 with 0 under the assumption the former is invalid for C++ - 
> > which is true - but 0 is inappropriate for C which is much worse.
> 
> A #define to 0 is, for the C language, last I checked valid.  You may not 
> like it, but welcome to C.

0 may be valid, but it doesn't work for variadic arguments.

> > Thus, I propose to remove the fix altogether.
> 
> Breaking all systems that are broken, isn't a good tradeoff.
> 
> Now, looking at the PR, in this case, one could add a bypass __GNUG__ to this 
> fix, and avoid the change on OpenBSD.  This would also fix the problem.  I do 
> not think removing the fix is a good idea.

Sure.

As you are objecting please take the PR and do a more proper fix then.
I don't really care about OpenBSD or AIX or Interix - I just tried to
be helpful.  So, now it's yours ;)

Thanks,
Richard.

Reply via email to