From 9c92c12fea17353c9e06735d19ec47a21fbed9f9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Wed, 28 Apr 2021 17:29:33 -0500 Subject: [PATCH] Prevent errno.h from including incompatible error codes with Winsock codes --- src/Platform.h | 6 ++++++ src/PlatformSockets.h | 23 ----------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/Platform.h b/src/Platform.h index 770a351..f2c4982 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -1,5 +1,11 @@ #pragma once +#ifdef _WIN32 +// Prevent bogus definitions of error codes +// that are incompatible with Winsock errors. +#define _CRT_NO_POSIX_ERROR_CODES +#endif + #include #include #include diff --git a/src/PlatformSockets.h b/src/PlatformSockets.h index 89feb41..5e5dffc 100644 --- a/src/PlatformSockets.h +++ b/src/PlatformSockets.h @@ -13,33 +13,10 @@ #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;