Reputation: 63
When I don't define WINVER, my (msvc9) build is peppered with warnings and it says it is defaulting to 0x0600 (Vista) but it builds OK. When I define WINVER = 0x501 (XP), I get this error :-
error C3861: 'htonl': identifier not found
I'd rather use WINVER=0x0501 than 0x0600 but I don't know how to fix it!
I noticed something in http://west-chamber-season-2.googlecode.com/svn-history/r2/trunk/wcs2_cli.c
#ifdef WINVER
#include <winsock.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
Do I need to do something odd like this? Any ideas?
Upvotes: 1
Views: 2037
Reputation: 33203
If you are compiling for windows then #include winsock2.h and ws2tcpip.h and link to ws2_32.lib. Also ensure you call WSAStartup
before you try any networking functions.
Upvotes: 1