Re: msys inet_pton strangeness

From: Alexander Lakhin <exclusion(at)gmail(dot)com>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: msys inet_pton strangeness
Date: 2024-09-29 05:00:00
Message-ID: ab4eed8b-fb56-01d0-ef79-9c34e5fc03eb@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello Thomas and Andrew,

28.09.2024 23:52, Thomas Munro wrote:
> On Sun, Sep 29, 2024 at 6:26 AM Andrew Dunstan <andrew(at)dunslane(dot)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;

Best regards,
Alexander

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2024-09-29 07:04:44 Re: Logical Replication of sequences
Previous Message Yugo Nagata 2024-09-29 03:46:35 Re: Add has_large_object_privilege function