From 4b4162c1a138f034993d99c487621128e299c374 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 30 Nov 2020 20:44:46 -0600 Subject: [PATCH] Fix redefinition warning for errno.h constants on Windows --- src/PlatformSockets.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PlatformSockets.h b/src/PlatformSockets.h index 3f5b613..ce65b52 100644 --- a/src/PlatformSockets.h +++ b/src/PlatformSockets.h @@ -12,10 +12,34 @@ #define LastSocketError() WSAGetLastError() #define SHUT_RDWR SD_BOTH + +// errno.h will include incompatible definitions of these +// values compared to what Winsock uses, so we must undef +// them to ensure the correct value is used. + +#ifdef EWOULDBLOCK +#undef EWOULDBLOCK +#endif #define EWOULDBLOCK WSAEWOULDBLOCK + +#ifdef EAGAIN +#undef EAGAIN +#endif #define EAGAIN WSAEWOULDBLOCK + +#ifdef EINPROGRESS +#undef EINPROGRESS +#endif #define EINPROGRESS WSAEINPROGRESS + +#ifdef EINTR +#undef EINTR +#endif #define EINTR WSAEINTR + +#ifdef ETIMEDOUT +#undef ETIMEDOUT +#endif #define ETIMEDOUT WSAETIMEDOUT typedef int SOCK_RET;