[英]Ws2tcpip.h not compiling
I'm making a bandwidth usage monitor using QT creator and every time I include Ws2tcpip.h I get a dozen of compilation errors like: error: redefinition of 'struct ip_mreq'我正在使用 QT creator 制作带宽使用监视器,每次我包含 Ws2tcpip.h 时,我都会遇到许多编译错误,例如:错误:'struct ip_mreq' 的重新定义
I only included the header file and still get many errors我只包含了 header 文件,但仍然有很多错误
#include "bandwidth_usage.h"
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
Bandwidth_Usage::Bandwidth_Usage()
{
}
int Bandwidth_Usage :: get () {
}
The including <windows.h>
and <winsock2.h>
order makes a difference.包含
<windows.h>
和<winsock2.h>
的顺序有所不同。
The following code works for me.以下代码对我有用。 Also see the accept function example .
另请参阅接受 function 示例。
#include <winsock2.h>
#include <WS2tcpip.h>
#include <stdio.h>
#include <windows.h>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.