Re: invalid conversion from `int*' to `socklen_t*'

From: Howard (alicebt_at_hotmail.com)
Date: 11/29/04


Date: Mon, 29 Nov 2004 18:02:28 GMT


"Abhijit Bhadra" <abhijit.bhadra@ca.com> wrote in message
news:67c9c69e.0411290114.77756058@posting.google.com...
> Hi ,
> I am using gcc version 3.3.2. While compiling this code
> struct sockaddr_in *CBaseSocket::GetSocketName()
> {
> socklen_t iLen;
> cCriticalSocket.Lock();
> // Do we have a socket?
> if (sSocket == INVALID_SOCKET)
> {
> cCriticalSocket.Unlock();
> return(NULL);
> };
> cCriticalSocket.Unlock();
>
> iLen = sizeof(struct sockaddr_in);
> if (!::getsockname(sSocket, (struct sockaddr *) &sTAddr, &iLen))
> return(&sTAddr);
>
> return(NULL);
> };
>
> I am getting this error while compiling :
>
> "invalid conversion from `int*' to `socklen_t*'"
>
> Can anyone help me to get rid of this error message ?
>
> Thanks,
> Abhijit

You shouldn't need it, but you might try casting &iLen as (socklen_t*), just
to see if it works.

(Are you getting any other errors? For example, are you getting an error
that "socklen_t" is not defined? That might also cause this error. Just
guessing, though.)

One other note: there's no reason for all those "struct" specifiers
scattered in your code. That looks like some old C code, not C++. Remove
them. The struct specifier is only needed for the original declaration of
the object, not when referring to objects of that type (or pointers to such
objects). So wherever you have "struct sockaddr", replace it with just
"sockaddr".

-Howard



Relevant Pages

  • Re: byte alignment/dynamic memory from heap x64
    ... I had seen the definition in the WDK header that uses ... declspec) and I was compiling with x64 compiler. ... struct and when my driver is loaded I dynamically allocate memory using these ... The documention for x64 states that SLIST_ENTRY and SLIST_HEADER must be 16 ...
    (microsoft.public.development.device.drivers)
  • Re: To C or not to C ... now what the hell to I do?
    ... Function mktime() Fix ... short version of struct tm when making a call to mktime ... This resulted in a longer struct tm. ... So clearly compiling under v8.3 gives you a couple more structure ...
    (comp.os.vms)
  • Re: VC2008 Bug: optimising static_cast to a virtual base gives C1001 internal compile error
    ... struct A: virtual B; ... it ICEs while _compiling_, not after the linker is done with it. ... I was able to repro it on 2008 Team Edition. ... If this is an issue in real code, adding #pragma optimizebefore ...
    (microsoft.public.vc.language)
  • Re: Function templates
    ... > You can also restrict T for the purpose of guiding overload resolution ... no instance of function template "SQ" matches the ... template struct can_multiply ...
    (comp.lang.cpp)