Winsock2 problem
umperio

When I include <winsock2.h> in Visual Studio 2003 I get tons of errors, can someone please tell me why?
Thank you everybody...:D

gillius

Because your code is wrong.

Oscar Giner

If you're using allegro, include only winalleg.h before allegro.h.

Rick

umperio, we need more info. I think that's what gillius is getting at.

decsonic
#include <allegro.h>
#include <winalleg.h>
#include <winsock2.h> //or winsock.h.. whatever its called 

Oscar Giner

Ah, yes, winalleg.h comes after allegro.h. But you should not include winsock2.h. winalleg already does it.

Krzysztof Kluczek

I'm using DevC++ and found that defining NOGDI define (-DNOGDI compiler option for MinGW) allows <allegro.h> and <windows.h> (or anything that includes it, like <winsock.h> and <vector>) to coexist. I don't know if it's proper solution, but it works for me all the time. :)

decsonic

that removes the GDI Driver tho.
There's a command like "-__HIDE-W32API" also :o

Oscar, winalleg includes windows.h.

X-G

-D__GTHREAD_HIDE_WIN32API. But that one will do nothing here; it only stops the STL stuff from including windows.h when using GCC.

decsonic: Read it again. winsock2.h, not windows.h.

Marco Radaelli

Uhm, maybe you can tell us which kind of errors you get?

umperio
#SelectExpand
1------ Build started: Project: ManaWorld, Configuration: Release Win32 ------ 2 3Compiling... 4map_server.cpp 5C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(109) : error C2011: 'fd_set' : 'struct' type redefinition 6 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(54) : see declaration of 'fd_set' 7C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(144) : warning C4005: 'FD_SET' : macro redefinition 8 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(88) : see previous definition of 'FD_SET' 9C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(153) : error C2011: 'timeval' : 'struct' type redefinition 10 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(97) : see declaration of 'timeval' 11C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(209) : error C2011: 'hostent' : 'struct' type redefinition 12 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(153) : see declaration of 'hostent' 13C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(222) : error C2011: 'netent' : 'struct' type redefinition 14 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(166) : see declaration of 'netent' 15C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(229) : error C2011: 'servent' : 'struct' type redefinition 16 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(173) : see declaration of 'servent' 17C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(241) : error C2011: 'protoent' : 'struct' type redefinition 18 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(185) : see declaration of 'protoent' 19C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(397) : error C2011: 'sockaddr_in' : 'struct' type redefinition 20 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(321) : see declaration of 'sockaddr_in' 21C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(407) : error C2011: 'WSAData' : 'struct' type redefinition 22 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(331) : see declaration of 'WSAData' 23C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(467) : warning C4005: 'SO_DONTLINGER' : macro redefinition 24 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(411) : see previous definition of 'SO_DONTLINGER' 25C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(524) : warning C4005: 'AF_IPX' : macro redefinition 26 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(469) : see previous definition of 'AF_IPX' 27C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(552) : warning C4005: 'AF_MAX' : macro redefinition 28 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(488) : see previous definition of 'AF_MAX' 29C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(558) : error C2011: 'sockaddr' : 'struct' type redefinition 30 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(494) : see declaration of 'sockaddr' 31C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(598) : error C2011: 'sockproto' : 'struct' type redefinition 32 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(503) : see declaration of 'sockproto' 33C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(637) : error C2011: 'linger' : 'struct' type redefinition 34 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(540) : see declaration of 'linger' 35C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(650) : warning C4005: 'SOMAXCONN' : macro redefinition 36 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(553) : see previous definition of 'SOMAXCONN' 37C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(675) : warning C4005: 'FD_READ' : macro redefinition 38 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(571) : see previous definition of 'FD_READ' 39C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(678) : warning C4005: 'FD_WRITE' : macro redefinition 40 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(572) : see previous definition of 'FD_WRITE' 41C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(681) : warning C4005: 'FD_OOB' : macro redefinition 42 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(573) : see previous definition of 'FD_OOB' 43C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(684) : warning C4005: 'FD_ACCEPT' : macro redefinition 44 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(574) : see previous definition of 'FD_ACCEPT' 45C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(687) : warning C4005: 'FD_CONNECT' : macro redefinition 46 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(575) : see previous definition of 'FD_CONNECT' 47C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(690) : warning C4005: 'FD_CLOSE' : macro redefinition 48 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(576) : see previous definition of 'FD_CLOSE' 49C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1622) : error C2375: 'accept' : redefinition; different linkage 50 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(744) : see declaration of 'accept' 51C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1643) : error C2375: 'bind' : redefinition; different linkage 52 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(749) : see declaration of 'bind' 53C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1662) : error C2375: 'closesocket' : redefinition; different linkage 54 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(754) : see declaration of 'closesocket' 55C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1681) : error C2375: 'connect' : redefinition; different linkage 56 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(756) : see declaration of 'connect' 57C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1702) : error C2375: 'ioctlsocket' : redefinition; different linkage 58 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(761) : see declaration of 'ioctlsocket' 59C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1723) : error C2375: 'getpeername' : redefinition; different linkage 60 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(766) : see declaration of 'getpeername' 61C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1744) : error C2375: 'getsockname' : redefinition; different linkage 62 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(771) : see declaration of 'getsockname' 63C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1767) : error C2375: 'getsockopt' : redefinition; different linkage 64 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(776) : see declaration of 'getsockopt' 65C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1788) : error C2375: 'htonl' : redefinition; different linkage 66 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(783) : see declaration of 'htonl' 67C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1805) : error C2375: 'htons' : redefinition; different linkage 68 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(785) : see declaration of 'htons' 69C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1822) : error C2375: 'inet_addr' : redefinition; different linkage 70 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(787) : see declaration of 'inet_addr' 71C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1839) : error C2375: 'inet_ntoa' : redefinition; different linkage 72 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(789) : see declaration of 'inet_ntoa' 73C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1857) : error C2375: 'listen' : redefinition; different linkage 74 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(791) : see declaration of 'listen' 75C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1875) : error C2375: 'ntohl' : redefinition; different linkage 76 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(795) : see declaration of 'ntohl' 77C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1892) : error C2375: 'ntohs' : redefinition; different linkage 78 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(797) : see declaration of 'ntohs' 79C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1912) : error C2375: 'recv' : redefinition; different linkage 80 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(799) : see declaration of 'recv' 81C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1937) : error C2375: 'recvfrom' : redefinition; different linkage 82 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(805) : see declaration of 'recvfrom' 83C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1963) : error C2375: 'select' : redefinition; different linkage 84 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(813) : see declaration of 'select' 85C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(1987) : error C2375: 'send' : redefinition; different linkage 86 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(820) : see declaration of 'send' 87C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2012) : error C2375: 'sendto' : redefinition; different linkage 88 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(826) : see declaration of 'sendto' 89C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2038) : error C2375: 'setsockopt' : redefinition; different linkage 90 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(834) : see declaration of 'setsockopt' 91C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2060) : error C2375: 'shutdown' : redefinition; different linkage 92 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(841) : see declaration of 'shutdown' 93C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2080) : error C2375: 'socket' : redefinition; different linkage 94 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(845) : see declaration of 'socket' 95C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2103) : error C2375: 'gethostbyaddr' : redefinition; different linkage 96 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(852) : see declaration of 'gethostbyaddr' 97C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2122) : error C2375: 'gethostbyname' : redefinition; different linkage 98 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(857) : see declaration of 'gethostbyname' 99C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2140) : error C2375: 'gethostname' : redefinition; different linkage 100 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(859) : see declaration of 'gethostname' 101C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2159) : error C2375: 'getservbyport' : redefinition; different linkage 102 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(863) : see declaration of 'getservbyport' 103C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2178) : error C2375: 'getservbyname' : redefinition; different linkage 104 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(867) : see declaration of 'getservbyname' 105C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2196) : error C2375: 'getprotobynumber' : redefinition; different linkage 106 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(871) : see declaration of 'getprotobynumber' 107C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2213) : error C2375: 'getprotobyname' : redefinition; different linkage 108 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(873) : see declaration of 'getprotobyname' 109C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2233) : error C2375: 'WSAStartup' : redefinition; different linkage 110 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(877) : see declaration of 'WSAStartup' 111C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2251) : error C2375: 'WSACleanup' : redefinition; different linkage 112 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(881) : see declaration of 'WSACleanup' 113C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2268) : error C2375: 'WSASetLastError' : redefinition; different linkage 114 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(883) : see declaration of 'WSASetLastError' 115C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2285) : error C2375: 'WSAGetLastError' : redefinition; different linkage 116 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(885) : see declaration of 'WSAGetLastError' 117C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2302) : error C2375: 'WSAIsBlocking' : redefinition; different linkage 118 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(887) : see declaration of 'WSAIsBlocking' 119C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2319) : error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage 120 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(889) : see declaration of 'WSAUnhookBlockingHook' 121C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2336) : error C2375: 'WSASetBlockingHook' : redefinition; different linkage 122 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(891) : see declaration of 'WSASetBlockingHook' 123C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2353) : error C2375: 'WSACancelBlockingCall' : redefinition; different linkage 124 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(893) : see declaration of 'WSACancelBlockingCall' 125C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2375) : error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage 126 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(895) : see declaration of 'WSAAsyncGetServByName' 127C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2402) : error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage 128 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(903) : see declaration of 'WSAAsyncGetServByPort' 129C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2428) : error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage 130 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(911) : see declaration of 'WSAAsyncGetProtoByName' 131C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2453) : error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage 132 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(918) : see declaration of 'WSAAsyncGetProtoByNumber' 133C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2478) : error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage 134 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(925) : see declaration of 'WSAAsyncGetHostByName' 135C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2505) : error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage 136 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(932) : see declaration of 'WSAAsyncGetHostByAddr' 137C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2528) : error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage 138 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(941) : see declaration of 'WSACancelAsyncRequest' 139C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock2.h(2548) : error C2375: 'WSAAsyncSelect' : redefinition; different linkage 140 C:\Programmi\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinSock.h(943) : see declaration of 'WSAAsyncSelect' 141map_server.cpp(24) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 142map_server.cpp(24) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 143 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 144map_server.cpp(24) : error C3861: 'recv': identifier not found, even with argument-dependent lookup 145map_server.cpp(101) : error C3861: 'WSAStartup': identifier not found, even with argument-dependent lookup 146map_server.cpp(102) : error C2440: '=' : cannot convert from 'SOCKET (__stdcall *)(int,int,int)' to 'SOCKET' 147map_server.cpp(102) : error C2440: '=' : cannot convert from 'SOCKET (__stdcall *)(int,int,int)' to 'SOCKET' 148 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 149map_server.cpp(102) : error C3861: 'socket': identifier not found, even with argument-dependent lookup 150map_server.cpp(106) : error C2440: '=' : cannot convert from 'u_short (__stdcall *)(u_short)' to 'u_short' 151map_server.cpp(106) : error C2440: '=' : cannot convert from 'u_short (__stdcall *)(u_short)' to 'u_short' 152 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 153map_server.cpp(106) : error C3861: 'htons': identifier not found, even with argument-dependent lookup 154map_server.cpp(107) : error C2440: '=' : cannot convert from 'unsigned long (__stdcall *)(const char *)' to 'u_long' 155map_server.cpp(107) : error C2440: '=' : cannot convert from 'unsigned long (__stdcall *)(const char *)' to 'u_long' 156 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 157map_server.cpp(107) : error C3861: 'inet_addr': identifier not found, even with argument-dependent lookup 158map_server.cpp(110) : error C2440: '=' : cannot convert from 'hostent *(__stdcall *)(const char *)' to 'hostent *' 159map_server.cpp(110) : error C2440: '=' : cannot convert from 'hostent *(__stdcall *)(const char *)' to 'hostent *' 160 There is no context in which this conversion is possible 161map_server.cpp(110) : error C3861: 'gethostbyname': identifier not found, even with argument-dependent lookup 162map_server.cpp(115) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const sockaddr *,int)' to 'int' 163map_server.cpp(115) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const sockaddr *,int)' to 'int' 164 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 165map_server.cpp(115) : error C3861: 'connect': identifier not found, even with argument-dependent lookup 166map_server.cpp(125) : error C3861: 'closesocket': identifier not found, even with argument-dependent lookup 167map_server.cpp(126) : error C3861: 'WSACleanup': identifier not found, even with argument-dependent lookup 168map_server.cpp(168) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 169map_server.cpp(168) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 170 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 171map_server.cpp(168) : error C3861: 'send': identifier not found, even with argument-dependent lookup 172map_server.cpp(171) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 173map_server.cpp(171) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 174 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 175map_server.cpp(171) : error C3861: 'recv': identifier not found, even with argument-dependent lookup 176map_server.cpp(174) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 177map_server.cpp(174) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,char *,int,int)' to 'int' 178 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 179map_server.cpp(174) : error C3861: 'recv': identifier not found, even with argument-dependent lookup 180map_server.cpp(192) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 181map_server.cpp(192) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 182 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 183map_server.cpp(192) : error C3861: 'send': identifier not found, even with argument-dependent lookup 184map_server.cpp(200) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 185map_server.cpp(200) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 186 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 187map_server.cpp(200) : error C3861: 'send': identifier not found, even with argument-dependent lookup 188map_server.cpp(213) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 189map_server.cpp(213) : error C2440: '=' : cannot convert from 'int (__stdcall *)(SOCKET,const char *,int,int)' to 'int' 190 This conversion requires a reinterpret_cast, a C-style cast or function-style cast 191map_server.cpp(213) : error C3861: 'send': identifier not found, even with argument-dependent lookup 192 193Build log was saved at "file://c:\Documents and Settings\Eugenio\Documenti\Visual Studio Projects\ManaWorld\Release\BuildLog.htm" 194ManaWorld - 96 error(s), 11 warning(s) 195 196 197---------------------- Done ---------------------- 198 199 Build: 0 succeeded, 1 failed, 0 skipped

This is what I get when I compile, if I use only <winsock.h> instead of <winsock2.h> I get no errors.

Marco Radaelli

Oh... so it may really be a problem with the #include order. Strange that the errors comes only with <winsock2.h>. Try to post your #include lines.

Oscar Giner

I made a program with allegro an winsock2, and I just included allegro.h and winalleg.h, and it worked. Including winsock2.h gives errors about redefinitions, so winalleg.h (or windows.h) already includes winsock2.h.

decsonic
Quote:

-D__GTHREAD_HIDE_WIN32API. But that one will do nothing here; it only stops the STL stuff from including windows.h when using GCC.

decsonic: Read it again. winsock2.h, not windows.h.

ah sorry, forgot that he said msvc :P
I Never trust any files to already be included, winsock depends on windows.h.

The way i posted above should work tho

Oscar Giner

Ok, I'll say it once again:

#include <allegro.h>
#include <winalleg.h>
#include <winsock2.h> //or winsock.h.. whatever its called 

just doesn't compile! Trust me, I've tried it. You MUST NOT include winsock2.h

decsonic

works fine here :o

Oscar Giner

what version of msvc do you have? It doesn't work with msvc6 (maybe an unpatched version).

decsonic

Was testing that with mingw(Yes Brain dead atm - Insomnia)
checking with msvc, hmm see the problem..
winsock.h is included automaticly, but when you include winsock2 you get problems

Edit

1//From Windows.h
2 
3#ifndef WIN32_LEAN_AND_MEAN
4#include <cderr.h>
5#include <dde.h>
6#include <ddeml.h>
7#include <dlgs.h>
8#ifndef _MAC
9#include <lzexpand.h>
10#include <mmsystem.h>
11#include <nb30.h>
12#include <rpc.h>
13#endif
14#include <shellapi.h>
15#ifndef _MAC
16#include <winperf.h>
17 
18#if(_WIN32_WINNT >= 0x0400)
19#include <winsock2.h>
20#include <mswsock.h>
21#else
22#include <winsock.h>
23#endif /* _WIN32_WINNT >= 0x0400 */

Thread #360420. Printed from Allegro.cc