Prevent errno.h from including incompatible error codes with Winsock codes

This commit is contained in:
Cameron Gutman 2021-04-28 17:29:33 -05:00
parent 3ae03998a2
commit 9c92c12fea
2 changed files with 6 additions and 23 deletions

View File

@ -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 <stdlib.h>
#include <string.h>
#include <stdint.h>

View File

@ -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;