Thread: Dead code in win32.h
src/include/port/win32.h contains (starting around line 270): /** Supplement to <errno.h>.*/ #undef EAGAIN #undef EINTR #define EINTR WSAEINTR #define EAGAIN WSAEWOULDBLOCK #undef EMSGSIZE #define EMSGSIZE WSAEMSGSIZE #undef EAFNOSUPPORT #define EAFNOSUPPORT WSAEAFNOSUPPORT #undef EWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK #undef ECONNRESET #define ECONNRESET WSAECONNRESET #undef EINPROGRESS #define EINPROGRESS WSAEINPROGRESS #undef ENOBUFS #define ENOBUFS WSAENOBUFS #undef EPROTONOSUPPORT #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #undef ECONNREFUSED #define ECONNREFUSED WSAECONNREFUSED #undef EBADFD #define EBADFD WSAENOTSOCK #undef EOPNOTSUPP #define EOPNOTSUPP WSAEOPNOTSUPP /** For Microsoft Visual Studio 2010 and above we intentionally redefine* the regular Berkeley error constants and set themto the WSA constants.* Note that this will break if those constants are used for anything else* than Windows Socketserrors.*/ #if _MSC_VER >= 1600 #pragma warning(disable:4005) #define EMSGSIZE WSAEMSGSIZE #define EAFNOSUPPORT WSAEAFNOSUPPORT #define EWOULDBLOCK WSAEWOULDBLOCK #define EPROTONOSUPPORT WSAEPROTONOSUPPORT #define ECONNRESET WSAECONNRESET #define EINPROGRESS WSAEINPROGRESS #define ENOBUFS WSAENOBUFS #define ECONNREFUSED WSAECONNREFUSED #define EOPNOTSUPP WSAEOPNOTSUPP #pragma warning(default:4005) #endif Perhaps I'm missing something, but if so, in what way is the "#if _MSC_VER >= 1600" stanza not totally useless given the immediately preceding macro redefinitions? And doesn't the comment above it apply just as much to the preceding definitions (other than the claim that it only happens in newer MSVC versions)? regards, tom lane
I wrote: > Perhaps I'm missing something, but if so, in what way is the > "#if _MSC_VER >= 1600" stanza not totally useless given the > immediately preceding macro redefinitions? Some rummaging in the git history says that that stanza did something when it was added (in 63876d3ba), but the later commit 73838b52 made it redundant by making the earlier set of definitions unconditional. Now it's merely confusing, so I'm going to take it out and repurpose the comment. regards, tom lane
On Fri, Apr 22, 2016 at 4:52 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > I wrote: >> Perhaps I'm missing something, but if so, in what way is the >> "#if _MSC_VER >= 1600" stanza not totally useless given the >> immediately preceding macro redefinitions? > > Some rummaging in the git history says that that stanza did something > when it was added (in 63876d3ba), but the later commit 73838b52 made > it redundant by making the earlier set of definitions unconditional. > Now it's merely confusing, so I'm going to take it out and repurpose > the comment. Going through that... That's indeed dead meat (found a bug on the way actually). -- Michael