Menu

Compilation error on VC 7.1

2003-06-27
2003-06-27
  • Nobody/Anonymous

    When I try to compile jwSMTP I get the following error:

    Compiling...
    mailer.cpp
    c:\dev\jwsmtp 1.21\mailer.cpp(307) : error C2440: 'type cast' : cannot convert from 'std::vector<_Ty>::const_iterator' to 'sockaddr *'
            with
            [
                _Ty=sockaddr_in
            ]
            No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

    HELP please!!

    thank you
    - Lukasz

     
    • John Wiggins

      John Wiggins - 2003-06-27

      Unfortunately I do not use this version of the compiler so I cannot compile the code on it to find a fix. However,
      The definition of adds is this:
      std::vector<sockaddr_in> adds;

      So it seems that the compiler does not know how to cast from a sockaddr* to an adds::iterator, as the sockaddr_in is not a sockaddr this is not surprising (had this problem with unix also recently). Try making a sockaddr temporary here and using that in the connect call instead

      i.e. instead of:
      #ifdef WIN32
               if(connect(s, (sockaddr*)address, sizeof(*address)) == SOCKET_ERROR)
      #else

      do this:
      #ifdef WIN32
               sockaddr temp;
               memcpy(&temp, &(*address), sizeof(temp));        
               if(connect(s, &temp, sizeof(temp)) == SOCKET_ERROR)
      #else

      I have no idea if this will work but give it a try. Sorry I could not be more helpful. I have already done this under the #else clause below this for unix compilation.

       

Log in to post a comment.