Microsoft Visual Studio 10.0\VC\INCLUDE\system_error: error C2065

时间:2022-11-04 09:59:59
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(23): error C2065: 'EAFNOSUPPORT' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(24): error C2065: 'EADDRINUSE' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(25): error C2065: 'EADDRNOTAVAIL' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(26): error C2065: 'EISCONN' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(27): error C2065: 'E2BIG' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(29): error C2065: 'EFAULT' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(30): error C2065: 'EBADF' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(31): error C2065: 'EBADMSG' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(32): error C2065: 'EPIPE' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(33): error C2065: 'ECONNABORTED' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(34): error C2065: 'EALREADY' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(35): error C2065: 'ECONNREFUSED' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(36): error C2065: 'ECONNRESET' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(37): error C2065: 'EXDEV' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(38): error C2065: 'EDESTADDRREQ' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(39): error C2065: 'EBUSY' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(40): error C2065: 'ENOTEMPTY' : undeclared identifier

1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(41): error C2065: 'ENOEXEC' : undeclared identifier
1>c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\system_error(42): error C2065: 'EEXIST' : undeclared identifier

分析:
<WinSock2.h>有如下宏定义
/*
* Windows Sockets errors redefined as regular Berkeley error constants.
* These are commented out in Windows NT to avoid conflicts with errno.h.
* Use the WSA constants instead.
*/
#if 0
#define EWOULDBLOCK WSAEWOULDBLOCK
#define EINPROGRESS WSAEINPROGRESS
#define EALREADY WSAEALREADY
#define ENOTSOCK WSAENOTSOCK
#define EDESTADDRREQ WSAEDESTADDRREQ
#define EMSGSIZE WSAEMSGSIZE
#define EPROTOTYPE WSAEPROTOTYPE
#define ENOPROTOOPT WSAENOPROTOOPT
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
#define EOPNOTSUPP WSAEOPNOTSUPP
#define EPFNOSUPPORT WSAEPFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define EADDRINUSE WSAEADDRINUSE
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
#define ENETDOWN WSAENETDOWN
#define ENETUNREACH WSAENETUNREACH
#define ENETRESET WSAENETRESET
#define ECONNABORTED WSAECONNABORTED
#define ECONNRESET WSAECONNRESET
解决方法:
注释掉
// #if 0
//#endif
在system_error中 添加<WinSock2.h>