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++ */

?

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.

> 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.

Reply via email to