gcc and NULL function pointers.

Doug Gwyn gwyn at smoke.brl.mil
Fri Jun 21 01:42:38 AEST 1991


In article <MR0CV2H at xds13.ferranti.com> peter at ficc.ferranti.com (Peter da Silva) writes:
>Oh, I know it's incorrect. It's also common enough that a compiler vendor
>on a system where 0 doesn't have the same size and bit pattern as (void *)0
>would be foolish to #define NULL as 0 in <stdio.h>.
>Yes, it's better that everyone write correct code. But be liberal with
>what you accept... after all, the person you're punishing with a B&D
>definition of NULL is your customer.

You're NOT doing your customer any favor by catering to his misconceptions.
What about systems where different pointer types have different sizes?
There is no way the implementation can fully compensate for the programmer
having incorrectly coded his use of the NULL macro, and by trying to
accommodate such abuse at all you're merely reinforcing the mistaken notion
that caused the programmer to make the mistake in the first place.  Sooner
or later it is going to catch up with him, and the sooner the better.



More information about the Comp.std.c mailing list