Roberto Waltman <> writes:
> pozz wrote:
>> ... my compiler (for 16 bits Fujtsu 16LX series microcontrollers) gives a warning for that.
>> For example:
>> argument passing incompatible pointer types:
>> expected `tcp_accept_fn' actual `void *': argument 2 of
>>`tcp_accept'
>
> In addition to what others wrote, that warning complains about
> incompatible types, not about the pointer being NULL.
> If you want a "clean compile", casting NULL into the type of function
> pointer expected will squelch the warning.
Yes, that will likely silence the warning -- but keep in mind
that it's a workaround for a compiler bug. (I don't mean
a "bug" in the sense that the compiler is necessarily non-conforming,
just that the warning is spurious.)
You do generally need to cast NULL to the expected pointer type when
calling variadic functions, but that's not what's happening here; the
compiler wouldn't know the expected type.
A couple of questions for the OP:
Does the compiler you're using claim to be conforming? If not, what
does its documentation say about the use of function pointers?
Since you didn't show us the full source of the program, we can't be
100% sure of what's going on. What happens when you compile this?
typedef void (*funcptr)(void);
void func(funcptr arg)
{
if (arg) {
arg();
}
}
int main(void)
{
func((void*)0);
return 0;
}
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"