Menu

1.3.1 compile problems on Solaris

Porting
2001-01-02
2001-01-04
  • Daniel Pape

    Daniel Pape - 2001-01-02

    On my Solaris (SunOS 5.7) box:

    > uname -a
    SunOS ocr1 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-2

    > g++ --version
    2.95.2

    For posix/inaddr.cpp, line 232:

        *this = htonl(INADDR_ANY);

    I get the following error (editted for post):

    c++ -DHAVE_CONFIG_H -I. -I. -I. -I../posix -g -O2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -c  -fPIC -DPIC inaddr.cpp -o .libs/inaddr.lo

    inaddr.cpp: In method `void cc_InetAddress::setAddress(const char *)':
    inaddr.cpp:232: ambiguous overload for `cc_InetAddress & = unsigned int'
    inaddr.cpp:109: candidates are: class cc_InetAddress & cc_InetAddress::operator =(const char *)
    inaddr.cpp:137:                 class cc_InetAddress & cc_InetAddress::operator =(const cc_InetAddress &)
    inaddr.cpp:128:                 class cc_InetAddress & cc_InetAddress::operator =(long unsigned int)
    make: *** [inaddr.lo] Error 1

    ----

    There seem to be two problems.

    The first, most obvious one, is a type-conversion error. On that version of Solaris, the function htonl() returns "uint32_t" which is typedef'ed to be "unsigned int", but the operator=() wants a "long unsigned int".

    The second problem is that on Solaris, the function htonl() can actually be defined to be a null function:

    (from /usr/include/sys/byteorder.h)
    #define htonl(x) (x)

    which will cause the line to actually be:

        *this = ((INADDR_ANY));

    which (again) ends up trying to give an "unsigned int" to the operator=().

    The (simple) fix I made for both of these problems is the following:

    > diff inaddr.cpp.orig inaddr.cpp
    232c232
    <               *this = htonl(INADDR_ANY);
    ---
    >               *this = (long unsigned int)htonl(INADDR_ANY);

    This may not be a big deal (since from surrounding comments in the code I gather that this bit of it may not be that important) ... but I figured I'd post this anyway in case the project admins want to do something with it.

     
    • David Sugar

      David Sugar - 2001-01-04

      Done for 1.3.2.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.