curl-library
Re: TFTP nits
Date: Tue, 6 Sep 2005 22:32:01 +0100
Daniel Stenberg wrote:
> On Mon, 5 Sep 2005, Gisle Vanem wrote:
>
> >>Mingw32 cross-compiled on Linux, warns on argument to in sendto(). I
> >>haven't yet check what it actually wants it to look like:
> >
> >sendto() wants 'const u_char*' in 2nd arg.
>
> Oh. But we can't blindly assume that u_char is universally available, and
> my Linux man page says it wants 'const void *' in the 2nd arg!
Historically the argument to sendto() was `char *' or `const char *'.
When a function's prototype says it takes `const void *', that doesn't
so much mean it "wants" that type as that it will accept any data
pointer type and convert it. (`void *' is special in that way, as you
probably know).
So if you cast the argument to `char *', that should be universally portable.
It should also be portable if you cast the argument to `void *', as
the only platforms on which that wouldn't work would be those where
the C compiler doesn't support the type `void *'.
What's not portable is if the argument has any pointer type which is
not compatible with `const char *'.
-- Jamie
Received on 2005-09-06