gcc and NULL function pointers.
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Sun Jun 23 07:20:22 AEST 1991
In article <25572 at well.sf.ca.us> Jef Poskanzer <jef at well.sf.ca.us> writes:
> Hey, I've got an idea: how about not using NULL? Using a 0 explicitly
> cast to the appropriate pointer type works perfectly for all machines
> and compilers. Furthermore, it makes the code more self-documenting
> and maintainable, and less error-prone.
Yeah. It's been a long time since I've used NULL in any program. When I
start maintaining someone else's code, the first thing I do is trash all
the NULLs. It's amazing how many bugs this catches. (Admittedly, they'd
be caught by ANSI prototypes too, but most C code isn't ANSI C.)
> Oh, wait. It means typing a few more characters. So much for that idea.
:-)
I'm not sure what people are arguing here. Yes, programmers should
always cast NULL appropriately if they use it at all, because there
exist vendors which #define NULL 0. Yes, vendors should define NULL as
((char *) 0) or ((void *) 0), because there exist programmers who use
NULL without casting and it's better to detect such misuse. What's the
issue?
---Dan
More information about the Comp.std.c
mailing list