C warning that I can't seem to track down
Tim Writer
tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Tue Aug 8 18:25:49 UTC 2006
Lennart Sorensen <lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org> writes:
> On Tue, Aug 08, 2006 at 09:30:07AM -0400, bob wrote:
> > In newer versions of the GCC compiler the block of C code:
> >
> > int length;
>
> You didn't specify, so perhaps it is a signed int.
>
> > ...
> >
> > if(getsockname(s, (struct sockaddr *)&sin, &length))
> >
> > gives a warning below
> >
> > socketUtils.c:259: warning: pointer targets in passing argument 3 of
> > 'getsockname' differ in signedness
> >
> >
> > I tracked it down to a define called "socklen_t". Damned if I can find
> > where that is defined.
> >
> > Any help would be appreciated. Thanks.
>
> socklen_t is defined as an unsigned 32 bit value. Try making your int
> unsigned as well.
The correct solution is to define length as:
socklen_t length;
as pointed out by an earlier poster. Otherwise, if sizeof(socklen_t) is not
the same as sizeof(int), casting &length to a pointer to socklen_t will be
disastrous.
Types like socklen_t are your friends. Use them to help you.
--
tim writer <tim-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> starnix inc.
647.722.5301 toronto, ontario, canada
http://www.starnix.com professional linux services & products
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list