Microsoft, in their infinite wisdom, decided to strike a major blow against portability in Visual Studio 2010 and onward. Previously BSD socket errno:s were left undefined and you could do things like: #define ECONNREFUSED WSAECONNREFUSED They've now decided to define all the BSD socket errors, but with incompatible numbers. So at best you'll now get a tonne of warnings about redefining constants, and at worst you'll get bad error handling because you're looking for the wrong value. Mingw-w64 has copied this behaviour, which means that this most definitely affects us sooner or later. References: http://msdn.microsoft.com/en-us/library/ms737828%28VS.85%29.aspx https://connect.microsoft.com/VisualStudio/feedback/details/509380/errno-h-socket-return-codes-now-inconsistent-with-wsagetlasterror http://sourceforge.net/p/mingw-w64/mingw-w64/ci/892eb7bde78572a4d6cd48705a21ab6ffeb5639d/ http://bugs.python.org/issue10469 http://sourceforge.net/p/tcl/patches/617/ http://www.mail-archive.com/curl-library@cool.haxx.se/msg05164.html We need to go over our components and make sure this doesn't break things.
We have three choices wrt which error codes to use on Windows: 1) Continue to use the WSA codes, ie ECONNREFUSED=10061. 2) Try to use POSIX codes as much as possible, ie ECONNREFUSED=111. However, those will never be reported by functions such as WSAGetLastError(), and not recognized by FormatMessage. 3) Try to use the new Microsoft definitions from errno.h, ie ECONNREFUSED=107. However, as far as I can tell, these are totally bogus and not valid neither in POSIX nor in the Windows API. The general consensus seems to be that the best solution is to stick with the old approach of using the WSA constants (solution 1) by undef-ing the new broken constants from Microsoft: Python: http://bugs.python.org/issue10469 Curl: http://www.mail-archive.com/curl-library@cool.haxx.se/msg05381.html reSIProcate: https://svn.resiprocate.org/rep/resiprocate/main/rutil/Socket.hxx
Fixed in 29822.
More in 29827.
We have decided to go for a more complete solution, with a new header file "winerrno.h" included in every project.
(In reply to comment #4) > We have decided to go for a more complete solution, with a new header file > "winerrno.h" included in every project. tlclient fixed in 29918.
(In reply to comment #4) > We have decided to go for a more complete solution, with a new header file > "winerrno.h" included in every project. OpenSSH fixed in 29920.
(In reply to comment #4) > We have decided to go for a more complete solution, with a new header file > "winerrno.h" included in every project. pcsctun fixed in r29932. tlclient tweaked in r29931. PulseAudio fixed in r29930. sercd fixed in r29929. unfs3 fixed in r29926. TigerVNC fixed in r29923.
The list of codes seems to be correct and complete. I also cannot find any old manual conversions in any code. It would be nice to confirm that it is included everywhere needed, but I'm not sure how to achieve that. This is going to have be good enough. Closing.
It also redefines not-socket error codes, like EINVAL, which breaks standard C APIs. Pulseaudio refuses to start because of this.
(In reply to comment #9) > It also redefines not-socket error codes, like EINVAL, which breaks standard C > APIs. Pulseaudio refuses to start because of this. Updated in 30343 and r30344. Committed upstream for TigerVNC, and reported upstream for PulseAudio: https://bugs.freedesktop.org/show_bug.cgi?id=90773 sercd and unfs3 are not fixed upstream.
Will test this on bug 2344.