Error in Sun studio 12's sysent.h ? - Solaris

This is a discussion on Error in Sun studio 12's sysent.h ? - Solaris ; Dave writes: >> sha@kelvin ~ $ cat /etc/release >> Solaris 10 8/07 s10x_u4wos_12b X86 >> Copyright 2007 Sun Microsystems, Inc. All Rights Reserved. >> Use is subject to license terms. >> Assembled 16 August 2007 >> >> >> It seems ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 21 to 23 of 23

Thread: Error in Sun studio 12's sysent.h ?

  1. Re: Error in Sun studio 12's sysent.h ?

    Dave writes:

    >> sha@kelvin ~ $ cat /etc/release
    >> Solaris 10 8/07 s10x_u4wos_12b X86
    >> Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
    >> Use is subject to license terms.
    >> Assembled 16 August 2007
    >>
    >>
    >> It seems that it's a problem with the developer releases, the server
    >> with which I've tested it runs the latest Solaris 10 update.

    >
    >
    > But I think the header on the non-developer one is at fault too.
    >
    > [man sethostname]
    >
    > kestrel / % cat /etc/release
    > Solaris 10 8/07 s10s_u4wos_12b SPARC
    > Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
    > Use is subject to license terms.
    > Assembled 16 August 2007
    >
    >
    > kestrel / % grep sethostname /usr/include/unistd.h
    >
    > So despite what the man page says, sethostname is not declared in
    > unistd.h on Solaris 10 update 4 on SPARC.


    sha@kelvin ~ $ grep sethostname /usr/include/unistd.h
    sha@kelvin ~ $

    Okay, here (amd64) the man page says that it should be in unistd.h, but
    it isn't ...


    Sebastian

  2. Re: Error in Sun studio 12's sysent.h ?

    gerryt wrote:
    >
    > unistd.h should have the define. Its missing. If you add it to SPARC
    > you get the same error as x86. The fault for me lies in
    > /opt/SUNWspro/prod/include/CC/sysent.h which redefines sethostname
    > as a "const"... Its a prototype clash.
    > Remove the const and all is well. Whats const for here anyway??
    >


    My guess it's there to avoid a compiler warning when passing a string
    literal to the function. It's still wrong as the prototype contradicts
    the man page.

    Some C standard library function have two overloads in the C++ standard
    library to avoid this issue, but because C does not have function
    overloading, they must not be declared as extern "C".

    --
    Ian Collins.

  3. Re: Error in Sun studio 12's sysent.h ?

    On Sat, 01 Dec 2007 09:36:22 +1300, Ian Collins wrote:
    > gerryt wrote:
    >>
    >> unistd.h should have the define. Its missing. If you add it to SPARC
    >> you get the same error as x86. The fault for me lies in
    >> /opt/SUNWspro/prod/include/CC/sysent.h which redefines sethostname
    >> as a "const"... Its a prototype clash.
    >> Remove the const and all is well. Whats const for here anyway??
    >>

    >
    > My guess it's there to avoid a compiler warning when passing a string
    > literal to the function. It's still wrong as the prototype contradicts
    > the man page.


    That's probably the reason. String literals in C are char[], whilst in
    C++ they are const char[]. Using char* arguments in C++ functions would
    require a cast.

    A bientot
    Paul
    --
    Paul Floyd http://paulf.free.fr

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2