Greetings,
I am having an issue with calling both winsock and winsock2 libraries but i can't seem to find where i have called winsock from.

I have a main.cpp calling a Socket.h
main.cpp contains the following includes:

#include "stdafx.h"

#include <iostream>
#include <vector>
#include <windows.h>
#include <windowsx.h>
#include <string>
#include "header.h" 

#include "Socket.h"

and Sock.h has the following:

#include <iostream>
#include <string>
#include <winsock2.h>
#include <ws2tcpip.h>

When I include Sock.h in main.cpp for some reason it gives me the following errors about redefinition:

1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2def.h(91) : warning C4005: 'AF_IPX' : macro redefinition
1>        c:\program files\microsoft sdks\windows\v6.0a\include\winsock.h(460) : see previous definition of 'AF_IPX'

and then it lists a whole bunch of errors with ws2tcpip.h like these:

1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2tcpip.h(757) : error C2146: syntax error : missing ';' before identifier 'Filter'
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2tcpip.h(757) : error C2065: 'Filter' : undeclared identifier
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2tcpip.h(759) : error C2065: 'SourceCount' : undeclared identifier
1>c:\program files\microsoft sdks\windows\v6.0a\include\ws2tcpip.h(760) : error C2065: 'Filter' : undeclared identifier

And i have it linked correctly. What could be causing this issue?

There are a couple workarounds for that problem. Read this link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.