码迷,mamicode.com
首页 > Windows程序 > 详细

#include <winsock2.h>报错的问题

时间:2015-02-04 14:43:59      阅读:534      评论:0      收藏:0      [点我收藏+]

标签:

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



以上数据需要包含文件#include <winsock2.h>



如果包含顺序为:
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include <winsock2.h>
#include "resource.h"
#include "Definition.h"

那么会出现一大堆错误,如下



1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(91): warning C4005: “AF_IPX”: 宏重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(460) : 参见“AF_IPX”的前一个定义
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(131): warning C4005: “AF_MAX”: 宏重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(479) : 参见“AF_MAX”的前一个定义
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(168): warning C4005: “SO_DONTLINGER”: 宏重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(402) : 参见“SO_DONTLINGER”的前一个定义
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(212): error C2011: “sockaddr”:“struct”类型重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(485) : 参见“sockaddr”的声明
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(390): error C2059: 语法错误:“常量”
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(390): error C3805: “常量”: 意外标记,应输入“}”或者“,”
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(524): warning C4005: “IN_CLASSA”: 宏重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(287) : 参见“IN_CLASSA”的前一个定义
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(530): warning C4005: “IN_CLASSB”: 宏重定义
1> c:\program files\microsoft sdks\windows\v7.0a\include\winsock.h(293) : 参见“IN_CLASSB”的前一个定义
1>c:\program files\microsoft sdks\windows\v7.0a\include\ws2def.h(536): warning C4005: “IN_CLASSC”: 宏重定义
*
*
*
*
*
*




现在将包含顺序改为:
包含顺序为:
#include <winsock2.h>
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#include "resource.h"
#include "Definition.h"



那么将没有任何编译错误。



编译环境:VS2010

#include <winsock2.h>报错的问题

标签:

原文地址:http://blog.csdn.net/ghevinn/article/details/43485277

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!