Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.std.c Subject: Re: gcc and NULL function pointers. Message-ID: <1146.Jun2221.20.2291@kramden.acf.nyu.edu> Date: 22 Jun 91 21:20:22 GMT References: <9752@cognos.UUCP> <25572@well.sf.ca.us> Organization: IR Lines: 23 In article <25572@well.sf.ca.us> Jef Poskanzer 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