On Thu, Jun 2, 2022 at 12:28 PM sisyphus <[email protected]> wrote:
> Hi, > In the Perl source, we hard code our own implementation of inet_ntop() > and inet_pton(). > This results in a fatal compile-time error if the Windows (ws2tcpip.h) > implementation is also present. > > I'm therefore looking for a portable way of detecting whether the compiler > is a mingw-w64 one && the Windows implementation of those 2 functions has > been found. > > #if !defined(__MINGW64_VERSION_MAJOR) || __GNUC__ < 4 || (__GNUC__ == 4 && > __GNUC__ < 8) || _WIN32_WINNT < 0x0600 || !defined(_WS2TCPIP_H_) > /*** the Windows implementation has not been found, and we use the Perl > one ***/ > #else > /*** the Windows implementation has been found; we must hide the Perl one > ***/ > #endif > > Does that look to be a sane way of doing it ? > > Note that I'm concerned only with mingw-w64 compilers. Oddly, this issue > hasn't arisen with MS compilers - though I've tested only with Visual > Studio 2019. > I'm not obliged to care (and I don't) if the compiler in use is neither > mingw-w64 nor non-recent MS. > > I noticed in mingw-w64 ports of gcc-4.7.3, that ws2tcpip.h makes no > mention of the 2 symbols "inet_ntop" and "inet_pton", but that both symbols > are present in gcc-4.8.2. > I'm therefore guessing that the 2 symbols first turned up in the mingw-w64 > port of gcc-4.8.0. > And I notice that even when they are present in ws2tcpip.h, it's only if > _WIN32__WINNT >= 0x600. > > Please let me know if you see corrections or improvements that should (or > could) be made. > > A couple of things have occurred to me since posting: 1) That there's no point in examining the condition "__GNUC__ < 4" where mingw-w64 ports of gcc are concerned. That condition will always be false. 2) That instead of referencing the version of gcc, I should be referencing the version of the mingw-w64 runtime. Which was the first runtime in which ws2tcpip.h defined the symbols inet_pton and inet_ntop ? (Or where might I find the answer ?) Those symbols are found in ws2tcpip.h in runtime 3.1, but not in runtime 2.0 ... so I'm guessing that runtime 3.0 is where they first appeared. Cheers, Rob _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
