else
AC_DEFINE_UNQUOTED(SOCKLEN_T, $wx_cv_type_getsockname3)
fi
+ dnl Do this again for getsockopt as it may be different
+ AC_CACHE_CHECK([what is the type of the fifth argument of getsockopt],
+ wx_cv_type_getsockopt5,
+ [
+ AC_TRY_COMPILE(
+ [
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ ],
+ [
+ socklen_t len;
+ getsockopt(0, 0, 0, 0, &len);
+ ],
+ wx_cv_type_getsockopt5=socklen_t,
+ [
+ dnl the compiler will compile the version with size_t
+ dnl even if the real type of the last parameter is int
+ dnl but it should give at least a warning about
+ dnl converting between incompatible pointer types, so
+ dnl try to use it to get the correct behaviour at
+ dnl least with gcc (otherwise we'd always use size_t)
+ CFLAGS_OLD="$CFLAGS"
+ if test "$GCC" = yes ; then
+ CFLAGS="$CFLAGS -Werror"
+ fi
+
+ AC_TRY_COMPILE(
+ [
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ ],
+ [
+ size_t len;
+ getsockopt(0, 0, 0, 0, &len);
+ ],
+ wx_cv_type_getsockopt5=size_t,
+ AC_TRY_COMPILE(
+ [
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ ],
+ [
+ int len;
+ getsockopt(0, 0, 0, 0, &len);
+ ],
+ wx_cv_type_getsockopt5=int,
+ wx_cv_type_getsockopt5=unknown
+ )
+ )
+
+ CFLAGS="$CFLAGS_OLD"
+ ]
+ )
+ ])
+
+ if test "$wx_cv_type_getsockopt5" = "unknown"; then
+ wxUSE_SOCKETS=no
+ AC_MSG_WARN([Couldn't find socklen_t synonym for this system])
+ else
+ AC_DEFINE_UNQUOTED(SOCKOPTLEN_T, $wx_cv_type_getsockopt5)
+ fi
AC_LANG_POP
fi
fi
# endif
#endif
-#else
- /* undefine for OSX - its really an int */
-# ifdef __DARWIN__
-# undef SOCKLEN_T
-# define SOCKLEN_T int
-# endif
#endif /* SOCKLEN_T */
+#ifndef SOCKOPTLEN_T
+#define SOCKOPTLEN_T SOCKLEN_T
+#endif
+
/*
* MSW defines this, Unices don't.
*/
else
{
int error;
- SOCKLEN_T len = sizeof(error);
+ SOCKOPTLEN_T len = sizeof(error);
getsockopt(m_fd, SOL_SOCKET, SO_ERROR, (char*) &error, &len);
if (m_establishing && !m_server)
{
int error;
- SOCKLEN_T len = sizeof(error);
+ SOCKOPTLEN_T len = sizeof(error);
m_establishing = false;
GSocketError GSocket::GetSockOpt(int level, int optname,
void *optval, int *optlen)
{
- if (getsockopt(m_fd, level, optname, (char*)optval, (SOCKLEN_T*)optlen) == 0)
+ if (getsockopt(m_fd, level, optname, (char*)optval, (SOCKOPTLEN_T*)optlen) == 0)
{
return GSOCK_NOERROR;
}
if (m_establishing && !m_server)
{
int error;
- SOCKLEN_T len = sizeof(error);
+ SOCKOPTLEN_T len = sizeof(error);
m_establishing = false;