我的项目有2个包含<Windows.h>.
项目编译好,但现在我需要包含<winsock2.h>
。根据我的理解,避免在许多[地方] [1]中描述的重新定义问题,我需要遵循规则 - include <winsock2.h> befor each <Windows.h>
。我在我的项目的两个地方都做过这个,但无论如何都有重新定义的问题。为什么我对简单rule <winsock2.h> befor each <Windows.h>
的理解有误?
错误:
Error 32 error C2011: 'sockaddr' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\ws2def.h 212
Error 33 error C2059: syntax error : 'constant' c:\program files (x86)\microsoft sdks\windows\v7.1a\include\ws2def.h 390
Error 34 error C3805: 'constant': unexpected token, expected either '}' or a ',' c:\program files (x86)\microsoft sdks\windows\v7.1a\include\ws2def.h 390
Error 40 error C2011: 'sockaddr_in' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\ws2def.h 583
Error 41 error C2011: 'fd_set' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 132
Error 43 error C2011: 'timeval' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 176
Error 44 error C2011: 'hostent' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 232
Error 45 error C2011: 'netent' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 245
Error 46 error C2011: 'servent' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 252
Error 47 error C2011: 'protoent' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 264
Error 48 error C2011: 'WSAData' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 360
Error 49 error C2011: 'sockproto' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 458
Error 50 error C2011: 'linger' : 'struct' type redefinition c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 500
Error 58 error C2375: 'accept' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1578
Error 59 error C2375: 'bind' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1600
Error 60 error C2375: 'closesocket' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1619
Error 61 error C2375: 'connect' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1638
Error 62 error C2375: 'ioctlsocket' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1659
Error 63 error C2375: 'getpeername' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1680
Error 64 error C2375: 'getsockname' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1701
Error 65 error C2375: 'getsockopt' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1724
Error 66 error C2375: 'htonl' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1745
Error 67 error C2375: 'htons' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1762
Error 68 error C2375: 'inet_addr' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1780
Error 69 error C2375: 'inet_ntoa' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1797
Error 70 error C2375: 'listen' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1815
Error 71 error C2375: 'ntohl' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1833
Error 72 error C2375: 'ntohs' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1850
Error 73 error C2375: 'recv' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1870
Error 74 error C2375: 'recvfrom' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1895
Error 75 error C2375: 'select' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1921
Error 76 error C2375: 'send' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1945
Error 77 error C2375: 'sendto' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1970
Error 78 error C2375: 'setsockopt' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 1996
Error 79 error C2375: 'shutdown' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2018
Error 80 error C2375: 'socket' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2039
Error 81 error C2375: 'gethostbyaddr' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2063
Error 82 error C2375: 'gethostbyname' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2083
Error 83 error C2375: 'gethostname' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2101
Error 84 error C2375: 'getservbyport' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2121
Error 85 error C2375: 'getservbyname' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2141
Error 86 error C2375: 'getprotobynumber' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2160
Error 87 error C2375: 'getprotobyname' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2178
Error 88 error C2375: 'WSAStartup' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2200
Error 89 error C2375: 'WSACleanup' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2219
Error 90 error C2375: 'WSASetLastError' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2236
Error 91 error C2375: 'WSAGetLastError' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2253
Error 92 error C2375: 'WSAIsBlocking' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2270
Error 93 error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2287
Error 94 error C2375: 'WSASetBlockingHook' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2304
Error 95 error C2375: 'WSACancelBlockingCall' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2321
Error 96 error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2343
Error 97 error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2370
Error 98 error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2396
Error 99 error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2421
Error 100 error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2446
Error 101 error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2473
Error 102 error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2496
Error 103 error C2375: 'WSAAsyncSelect' : redefinition; different linkage c:\program files (x86)\microsoft sdks\windows\v7.1a\include\winsock2.h 2517