-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inet_pton: fix include on windows to get prototype #1639
Conversation
lib/inet_pton.h
Outdated
@@ -29,6 +29,9 @@ int Curl_inet_pton(int, const char *, void *); | |||
#ifdef HAVE_INET_PTON | |||
#ifdef HAVE_ARPA_INET_H | |||
#include <arpa/inet.h> | |||
#elif defined(HAVE_WINSOCK2_H) | |||
/* inet_pton() exists in Windows XP or later */ | |||
#include <winsock2.h> | |||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@badger inet_pton() is declared in ws2tcpip.h
c2f7973
to
a2b4878
Compare
@Jan-E: thanks! Pushed update just now. |
Simply including ws2tcpip.h instead of winsock2.h didn't work either. I gave up and now provide an |
Coverage decreased (-0.04%) to 74.4% when pulling be36f627e860910beb132474096cd8730689cd29 on bagder/inet_pton-windows into fa289ea on master. |
In my Windows 10 SDK and MinGW-w64's w32api, it's in ws2tcpip.h. I couldn't find it at all in the original MinGW's w32api. But it's only defined when targeting Windows Vista and later. Are you maybe using MinGW? It targets Windows 2000 (MinGW) / XP (MinGW-w64) by default. Defining the prototype unconditionally might be dangerous as the program won't start on Windows XP and lower anymore even if compiled with the correct target Windows version. |
Well, the prototype isn't what will make curl use it, but it removes the warning here. In this case, cmake detects the function and sets HAVE_INET_PTON and then we'll use it in the code. Of course the output binary won't work on old windows.
No, look at the appveyor builds. They're all built with three different versions of MSVC. As @snikulov pointed out on the mailing list , the warnings I couldn't get rid of is probably because I'm not sure what the correct fix for that is... |
inet_pton() exists on Windows and gets used by our cmake builds. Make sure the correct header file is included to avoid compiler warnings.
... and make sure inet_pton is always checked for when *not* using Windows, which is a regression from 4fc6ebe. Idea-by: Sergei Nikulov
be36f62
to
a63d761
Compare
Pushed a new version now that bumps the lowest windows version required if ENABLE_INET_PTON is set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I just wanted to propose something like that too :-)
ENABLE_INET_PTON hasn't been released yet, has it? Not being familiar with CMake, as it's Windows-specific, maybe we should go the other way round and make the Windows target version configurable? Otherwise, it may get complicated if more functions only available in even later Windows versions are introduced. |
It's not been released, and even if it had, we're not that strict on keeping the build scripts "compatible". But sure, I'm certainly not against that - it sounds like a more sensible approach. Windows is a platform where I'm not working myself so I limit my amount of fiddling there, relying on others... Feel like having a go at it? |
Yes, if noone familiar with CMake volunteers, I'll try to do that. Might take a while though because I'm currently moving and have limited internet access. |
Okay, no worries. I think I'll still merge this PR once it looks okay so at least the current approach works better, and then we can move to a better approach in a second step. |
... by checking the POLLIN define, as the header file checks don't work on Windows.
inet_pton() exists on Windows and gets used by our cmake builds. Make
sure the correct header file is included to avoid compiler warnings.