Home > Software design >  Ws2tcpip.h not compiling
Ws2tcpip.h not compiling

Time:01-10

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'

I only included the header file and still get many errors

#include "bandwidth_usage.h"
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
Bandwidth_Usage::Bandwidth_Usage()
{

}

int Bandwidth_Usage :: get () {

}

CodePudding user response:

The including <windows.h> and <winsock2.h> order makes a difference.
The following code works for me. Also see the accept function example.

#include <winsock2.h>
#include <WS2tcpip.h>
#include <stdio.h>
#include <windows.h>
  • Related