# Include & lt; winsock2.h & gt; error,

Source: Internet
Author: User

# Include <winsock2.h> error,
# Define PORT 5150
# Define DATA_BUFSIZE 8192

Typedef struct _ SOCKET_INFORMATION {
CHAR Buffer [DATA_BUFSIZE];
WSABUF DataBuf;
SOCKET Socket;
WSAOVERLAPPED Overlapped;
DWORD BytesSEND;
DWORD BytesRECV;
} SOCKET_INFORMATION, * LPSOCKET_INFORMATION;

Dword winapi ProcessIO (LPVOID lpParameter );

DWORD EventTotal = 0;
WSAEVENT EventArray [WSA_MAXIMUM_WAIT_EVENTS];
LPSOCKET_INFORMATION SocketArray [WSA_MAXIMUM_WAIT_EVENTS];
CRITICAL_SECTION CriticalSection;



The above data must contain files # include <winsock2.h>



If the include order is:
# Include <stdio. h>
# Include <windows. h>
# Include <commctrl. h>
# Include <winsock2.h>
# Include "resource. h"
# Include "Definition. h"

There will be a lot of errors, as shown below:



1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (91): warning C4005: "AF_IPX": Macro redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (460): see the previous definition of "AF_IPX ".
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (131): warning C4005: "AF_MAX": Macro redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (479): see the previous definition of "AF_MAX"
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (168): warning C4005: "SO_DONTLINGER": Macro redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (402): see the previous definition of "SO_DONTLINGER"
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (212): error C2011: "sockaddr": "struct" type redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (485): See the sockaddr statement.
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (390): error C2059: syntax error: "constant"
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (390): error C3805: "constant": Unexpected mark. Enter "}" or ","
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (524): warning C4005: "IN_CLASSA": Macro redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (287): see the previous definition of "IN_CLASSA"
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (530): warning C4005: "IN_CLASSB": Macro redefinition
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ winsock. h (293): see the previous definition of "IN_CLASSB"
1> c: \ program files \ microsoft sdks \ windows \ v7.0a \ include \ ws2def. h (536): warning C4005: "IN_CLASSC": Macro redefinition
*
*
*
*
*
*




Now, change the include order:
The include order is as follows:
# Include <winsock2.h>
# Include <stdio. h>
# Include <windows. h>
# Include <commctrl. h>
# Include "resource. h"
# Include "Definition. h"



There will be no compilation errors.



Compiling environment: VS2010

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.