这是头文件包含顺序的问题,原因与解决办法见下面代码的注释。

/*
包含下面这两个头文件时,必须把winsock2.h放在前面
否则编译报错,N多的重定义错误:例如 error C2011: 'fd_set' : 'struct' type redefinition
*/
#include <WinSock2.h>
#include <Windows.h> int main(int argc, _TCHAR* argv[])
{
Sleep();
return ;
}
其实可以不包含Windows.h,因为在winsock2.h中已经包含的windows.h

如果是很多的文件的话,找包含关系太繁琐,可以直接把 winsock2.h 的包含放在cpp最前面。

为什么会这样呢?头文件的包含还要求顺序,在MSDN中却没有解释。
只能说是微软的头文件写的有问题了。

VC中编译报错:error C2011: 'fd_set' : 'struct' type redefinition的更多相关文章

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

    在socket编程的过程中头文件中 #include <windows.h> #include "stdafx.h" #include "WinSock2.h ...

  2. 解决error C2011: 'fd_set' : 'struct' type redefinition的方法

    http://www.cnblogs.com/ark-zhang/archive/2013/06/19/3144383.html   首先说明这个问题由于重复定义引起的编译错误. 先说明解决方法,然后 ...

  3. wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法

    内容提要:wince6.0编译报错:"error C2220: warning treated as error - no 'object' file generated" 原因是 ...

  4. 编译报错dereferencing pointer to incomplete type

    关于编译报错“dereferencing pointer to incomplete type... 多是没找到结构体的定义,可以在本地复制其定义试试. 参考: http://my.oschina.n ...

  5. Spark程序编译报错error: object apache is not a member of package org

    Spark程序编译报错: [INFO] Compiling 2 source files to E:\Develop\IDEAWorkspace\spark\target\classes at 156 ...

  6. 关于编译报错“dereferencing pointer to incomplete type...

    今天同事问了我一个问题,他make的时候报错,“第201行:dereferencing pointer to incomplete type”,我随即查阅了很多资料,也没看出个所以然.最后问题得到了解 ...

  7. Android studio中的一次编译报错’Error:Execution failed for task ':app:transformClassesWithDexForDebug‘,困扰了两天

    先说下背景:随着各种第三方框架的使用,studio在编译打包成apk时,在dex如果发现有相同的jar包,不能创建dalvik虚拟机.一个apk,就是一个运行在linux上的一个虚拟机. 上图就是一直 ...

  8. 安卓中运行报错Error:Execution failed for task ':app:transformClassesWithDexForDebug'解决

    在androidstuio中运行我的未完项目,报错: Error:Execution failed for task ':app:transformClassesWithDexForDebug'.&g ...

  9. Keil C51编译报错error C141: syntax error

    错误代码: typedef unsigned char uchar uchar KeyRowColumnScan() { GPIO_KEY = 0x0f; uchar key_value = ; // ...

随机推荐

  1. host文件的用处

    做Flash开发的人员免不了接触host文件. 1:首先你注册Flash软件.FlashBuilder都需要先修改host,然后再安装的.(具体的修改时在etc包里找到host文件,把一堆adobe的 ...

  2. SpringMVC---400错误The request sent by the client was syntactically incorrect ()

    在SpringMVC中使用@RequestBody和@ModelAttribute注解时遇到了很多问题,现记录下来. @ModelAttribute这个注解主要是将客户端请求的参数绑定参数到一个对象上 ...

  3. 【C#】C#操作Excel文件(转)

    实现C#与Excel文件的交互操作,实现以下功能: 1.DataTable 导出到 Excel文件 2.Model数据实体导出到 Excel文件[List<Model>] 3.导出数据到模 ...

  4. 学习笔记之The Intelligent Investor, Rev. Ed

    The Intelligent Investor, Rev. Ed https://www.safaribooksonline.com/library/view/the-intelligent-inv ...

  5. [VS2013]发布网站时修改配置文件

    本文来自:https://msdn.microsoft.com/en-us/library/ee942158.aspx#encrypt_webconfig Web Deployment FAQ for ...

  6. selector的小箭头去除

    selector的小箭头去除 .not-arrow{ -webkit-appearance:none; -moz-appearance:none; appearance:none; /*去掉下拉箭头* ...

  7. 类实例化对象可以访问静态(static)方法,但是不能访问静态属性。

    类-> 访问->静态方法(类的方法)->可以 类 ->访问->普通方法(对象的方法)->不可以(虽然方法里不用$this关键字时,可以!但不支持这种写法) 类-&g ...

  8. [UE4]修改相机裁剪距离

    在UE4中,相机距离一个物体太近,物体就会被裁剪,这个距离是一个全局设定,无法单个相机设置. 项目设置:

  9. nginx 1.14.0 配置部署 thinkphp 5.1

    开始接触NGINX,配置tp5配了半天,找不到具体原因,于是用网上搜索到的配置复制粘贴搞定. 感谢 https://blog.csdn.net/qq_36431213/article/details/ ...

  10. 实现textview竖排文字效果

    文字效果