Please use NULL instead of 0 whenever you have a pointer!
Guy Harris
guy at rlgvax.UUCP
Sun Jan 15 06:18:49 AEST 1984
Actually, in <stdio.h> NULL is defined as 0, which is really as it should
be. So whether you use 0 or NULL makes no difference (unless somebody
made the mistake of defining NULL as "(char *)0"); you still have to
cast it explicitly. Then again, that's what "lint" is for; it's a good
idea to run "lint" on any program which isn't a quick throw-away or very
small and written by somebody you *know* won't make type errors - on the
other hand, I don't know anybody like that, myself included.
(If NULL were defined as "(char *)0", "lint" would get gastric distress
whenever NULL were passed as a pointer argument to a routine which expected
an "int *" or something like that. Furthermore, if you tried to assign
"(char *)0" to an "int *" variable, PCC would justifiably complain about
an illegal pointer combination. C doesn't have the notion of a generic
"null pointer", it has a "null pointer to char" which is distinct from
"null pointer to int" which is distinct from "null pointer to
(struct proc)"....)
Guy Harris
{seismo,ihnp4,allegra}!rlgvax!guy
More information about the Comp.unix.wizards
mailing list