Can't include Winsock2.h in MSVC 2010

后端 未结 2 1400
夕颜
夕颜 2021-01-04 08:01

I cannot include WinSock2.h in a msvc++2010 project. At first I though it was something I was doing wrong, so I created an empty project to test my sanity. The empty project

相关标签:
2条回答
  • 2021-01-04 08:22

    I made sure that an #include "Winsock2.h" is before any #include "windows.h" and "#include "Winsock.h" and this solved the case.

    Just a matter of patience, look at includes one by one and establish this order, first #include "Winsock2.h" then #include "windows.h"

    I checked the recursive includes, I spotted the header files which include (recursively) some #include "windows.h" and "#include "Winsock.h"and write a#include "Winsock2.h". in this files, i added#include "Winsock2.h"` as the first include.

    0 讨论(0)
  • 2021-01-04 08:26

    I believe you are getting these errors because windows.h will include winsock.h. Reverse the order of your includes so that WinSock2.h comes before windows.h. WinSock2.h has some #defines in it to keep windows.h from including winsock.h

    0 讨论(0)
提交回复
热议问题