解决ERROR C2011: 'FD_SET' : 'STRUCT' TYPE REDEFINITION问题

在socket编程的过程中头文件中

#include <windows.h>
#include "stdafx.h"
#include "WinSock2.h"

 

在编译的时候会报错 :error C2011: 'fd_set' : 'struct' type redefinition

解决方法

在所有的#include <windows.h>前使用#define WIN32_LEAN_AND_MEAN,如:

#define WIN32_LEAN_AND_MEAN
#include 
<windows.h>

这样编译就成功了。原因还不清楚。

posted @ 2013-09-28 12:47  zlog  阅读(331)  评论(0编辑  收藏  举报