在项目文件中包含 winsock2.h.
Including winsock2.h, in a file of a project.
在 -
中遇到很多错误WinSock2.h(109) : error C2011: 'fd_set' : 'struct' 类型重新定义
带有相应的 -WinSock.h(54) : 见'fd_set'的声明
我没有看到任何标题中包含 winsock.h.
I don't see winsock.h included in any of the headers.
项目中是否有任何设置可能导致这种情况?
Are there any setting in the project that may be causing this?
编辑
但是,我在另一个文件中使用 windows.h:
http://cboard.cprogramming.com/windows-programming/41212-奇怪的msvc-winsock2-compile-error.html
编辑 2
在标题中我有:
EDIT 2
In the header I have:
#include <winsock2.h>
#include <iphlpapi.h>
#include "MyFilesFileX.h" <-which #include <windows.h>
我有根据的猜测是包含标题的顺序,即首先包含 winsock2.h(第一个含义在 windows 之前.h),或者在包含 windows.h 之前定义 WIN32_LEAN_AND_MEAN,这样可以防止 windows.h 包含 winsock v1.
My educated guess would be the order of included headers, i.e. include winsock2.h first (with first meaning before windows.h), or define WIN32_LEAN_AND_MEAN before including windows.h, which prevents windows.h from including winsock v1.
#include <winsock2.h>
#include <windows.h>
-或-
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
这篇关于WinSock2.h 中的重新定义错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
fpermissive 标志有什么作用?What does the fpermissive flag do?(fpermissive 标志有什么作用?)
如何在我不想编辑的第 3 方代码中禁用来自 gccHow do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit?(如何在我不想编辑的第 3 方代码中禁
使用 GCC 预编译头文件Precompiled headers with GCC(使用 GCC 预编译头文件)
如何在 OS X 中包含 omp.h?How to include omp.h in OS X?(如何在 OS X 中包含 omp.h?)
如何让 GCC 将 .text 部分编译为可写在 ELF 二进制文How can I make GCC compile the .text section as writable in an ELF binary?(如何让 GCC 将 .text 部分编译为可写在 ELF 二进制文件中?)
GCC、字符串化和内联 GLSL?GCC, stringification, and inline GLSL?(GCC、字符串化和内联 GLSL?)