Why does lint complain about this?
Mark A Terribile
mat at mole-end.UUCP
Thu Apr 27 09:38:06 AEST 1989
In article <75688 at ti-csl.csc.ti.com>, ramey at m2.csc.ti.com (Joe Ramey) writes:
> try(0);
> ...
> try(foo)
> char *foo;
> {
> trylint.c:
> trylint.c(7): warning: argument foo unused in function try
> try, arg. 1 used inconsistently trylint.c(8) :: trylint.c(3)
> Why does lint say that the arg. is used inconsistently? I thought
> that zero could be assigned to any pointer type. ...
The problem is that the compiler (or LINT) doesn't know that what must
actually be passed is a char* .
Thus, the compiler could pass a 16-bit zero to a routine expecting a 32-bit
pointer. This is why function prototypes (ANSI C, C++) are better than LINT.
(Oh, do I expect a debate on that last statement!)
You should write
try( (char *) 0 );
in your sample code.
--
(This man's opinions are his own.)
>From mole-end Mark Terribile
More information about the Comp.lang.c
mailing list