I put this at the top #include <winsock2.h> & my code compiled, so does this mean will take winsock2.h as the main winsock header & ignore the old version?
I never expected the order of headers is kind of important. Can you explain why this is important & when such situation usually occurs?
Main Topics
Browse All Topics





by: itsmeandnobodyelsePosted on 2009-01-25 at 00:42:44ID: 23460103
The problem is that both winsock.h and winsock2.h were included which have most definitions in common. winsock2.h knows of winsock.h but not the other way rounde. Hence, you need to include winsock2.h *before* winsock.h. If using stdafx.h you should try to include winsock2.h as early as it compiles. If not, try to include winsock2.h as the very first include in each cpp. If this doesn't help or give other errors, open the winsock.h and check which macro protects from including it twice.. It should be like
#ifdef _winsock_h_included_
#define _winsock_h_included_
if found define the _winsock_h_included_ as a preprocessor macro in your project setting (simply add it to the other macros like _WIN32)