[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libssh and Visual C++ (again)


I agree, I haven't found a good way to handle ssize_t definition...
The problem is that there is no standard for ssize_t definition, except
under linux
Some define it as int, other as long, and under WIN64 platforms, it may by
__int64
I noticed that libarchive has an "internal" definition for ssize_t used by
library's source code, and has an "external" definition named __LA_SSIZE_T
used by library's users.
Like this:

#if defined(_WIN32) && !defined(__CYGWIN__)
# define        __LA_INT64_T    __int64
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
#  define       __LA_SSIZE_T    ssize_t
# elif defined(_WIN64)
#  define       __LA_SSIZE_T    __int64
# else
#  define       __LA_SSIZE_T    long
# endif
#else
# include <unistd.h>  /* ssize_t */
# if defined(_SCO_DS)
#  define       __LA_INT64_T    long long
# else
#  define       __LA_INT64_T    int64_t
# endif
# define        __LA_SSIZE_T    ssize_t
#endif

openssl library uses the type ossl_ssize_t as follows:
#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && macintosh==1 &&
!defined(MAC_OS_GUSI_SOURCE)
#  define ossl_ssize_t long
#endif
#ifdef OPENSSL_SYS_MSDOS
#  define ossl_ssize_t long
#endif
#if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) ||
defined(OPENSSL_SYS_SUNOS)
#  define ssize_t int
#endif
#if defined(__ultrix) && !defined(ssize_t)
#  define ossl_ssize_t int
#endif
#ifndef ossl_ssize_t
#  define ossl_ssize_t ssize_t
#endif
I think that libssh should have the same approach, and define something
like ssh_ssize_t for its interface, and use ssize_t only for internal
structures invisible from outside

Regards
Christophe Baribaud
2012/9/21 Andreas Schneider <asn@xxxxxxxxxxxxxx>

> On Thursday 20 September 2012 11:56:35 you wrote:
> > The same patches as before, using git
>
> Hi Christophe,
>
>
> I'm fine with patch #1 and #2. I don't like patch #3. I think we should
> check
> for the type with CHECK_TYPE_SIZE() in cmake and then use
>
> #ifdef HAVE_SSIZE_T
> ...
> #endif
>
>
>         -- andreas
>
> --
> Andreas Schneider                   GPG-ID: F33E3FC6
> www.cryptomilk.org                asn@xxxxxxxxxxxxxx
>
>
>

Follow-Ups:
Re: libssh and Visual C++ (again)Andreas Schneider <asn@xxxxxxxxxxxxxx>
References:
libssh and Visual C++ (again)Christophe Baribaud <christophe.baribaud@xxxxxxxxx>
Re: libssh and Visual C++ (again)Andreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org