I've run into this myself while trying to test ITS#9069 on Windows.
In my MinGW environment, <sys/socket.h> does not define socklen_t, so portable.h:1116 does '#define socklen_t int'. However, <ac/socket.h> includes <ws2tcpip.h> which does typedef socklen_t.
base64.c includes "portable.h" first and then <ac/socket.h> later. This second include triggers the error as the original typedef essentially becomes "typedef int int".
I think we can fix it by searching the Windows header as well, avoiding the #define appearing in "portable.h".
https://github.com/openldap/openldap/compare/openldap:master...rtandy:its838...