On 2024-09-29 Su 1:00 AM, Alexander Lakhin wrote:
Hello Thomas and Andrew,
28.09.2024 23:52, Thomas Munro wrote:
On Sun, Sep 29, 2024 at 6:26 AM Andrew Dunstan <andrew@dunslane.net> wrote:
We should have included ws2tcpip.h, which includes this:
#define InetPtonA inet_pton
WINSOCK_API_LINKAGE INT WSAAPI InetPtonA(INT Family, LPCSTR pStringBuf, PVOID pAddr);
It's conditioned on (_WIN32_WINNT >= 0x0600), but that should be true.
Can you print out the value to be sure? I can't imagine they'd set it
lower themselves or make it go backwards in an upgrade, but perhaps
it's somehow not being set at all, and then we do:
#if defined(_MSC_VER) && _MSC_VER >= 1900
#define MIN_WINNT 0x0600
#else
#define MIN_WINNT 0x0501
#endif
In 16 we don't do that anymore, we just always set it to 0x0A00
(commit 495ed0ef2d72). And before 15, we didn't want that function
yet (commit c1932e542863).
FWIW, I'm observing the same here.
For a trivial test.c (compiled with the same command line as
fe-secure-common.c) like:
"===_WIN32"
_WIN32;
"===_WIN32_WINNT";
_WIN32_WINNT;
with gcc -E (from mingw-w64-ucrt-x86_64-gcc 14.2.0-1), I get:
"===_WIN32"
1;
"===_WIN32_WINNT";
_WIN32_WINNT;
That is, _WIN32_WINNT is not defined, but with #include <windows.h> above,
I see:
"===_WIN32_WINNT";
0x603
With #include "postgres_fe.h" (as in fe-secure-common.c) I get:
"===_WIN32_WINNT";
0x0501;
Yeah, src/include/port/win32/sys/socket.h has:
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
I'm inclined to think we might need to reverse the order of the last two. TBH I don't really understand how this has worked up to now.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com