[Xapian-tickets] [Xapian] #821: SOCKLEN_T not defined when compiling with mingw32.

Xapian nobody at xapian.org
Thu Apr 27 00:55:06 BST 2023


#821: SOCKLEN_T not defined when compiling with mingw32.
--------------------------+-------------------------------
 Reporter:  mgautier      |             Owner:  Olly Betts
     Type:  defect        |            Status:  new
 Priority:  normal        |         Milestone:
Component:  Build system  |           Version:  1.4.22
 Severity:  normal        |        Resolution:
 Keywords:                |        Blocked By:
 Blocking:                |  Operating System:  Linux
--------------------------+-------------------------------
Comment (by Olly Betts):

 `SOCKLEN_T` is probed by configure (using the `XAPIAN_TYPE_SOCKLEN_T`
 macro defined in `m4/xapian_type_socklen_t.m4` which tries to compile:

 {{{
 $t len;
 getsockopt(0, 0, 0, 0, &len);
 }}}

 with `$t` being each of `socklen_t`, `int`, `size_t`, `unsigned`, `long`,
 `unsigned long` in turn until it finds one which works.

 I think you must be getting `SOCKLEN_T` set to `socklen_t` (since if
 `socklen_t` isn't defined in the probe it'll fail with that then succeed
 with `int`) so we should be able to just leave the `SOCKLEN_T` alone and
 sort out why `socklen_t` isn't available here.  Changing `SOCKLEN_T` to
 `socklen_t` here would likely break the build with MSVC.  Changing to
 `int` would work but seems less future-proof, and given we already have
 the machinery for probing for this why bake in an assumption for a
 particular platform?

 The headers used for the probe are:

 {{{
         #include <sys/types.h>
         #if defined __WIN32__ || defined _WIN32
         # include <winsock2.h>
         #else
         # include <sys/socket.h>
         #endif
 }}}

 `safewinsock2.h` just includes `safewindows.h` before `<winsock2.h>`
 (because otherwise `<winsock2.h>` can include `<windows.h>` without our
 various workarounds for its stupidities), so probably we can just include
 `<sys/types.h>` here to fix this in a way which matches how we probed
 `SOCKLEN_T`?
-- 
Ticket URL: <https://trac.xapian.org/ticket/821#comment:2>
Xapian <https://xapian.org/>
Xapian


More information about the Xapian-tickets mailing list