Windows网络编程包含WinSock2.h报错问题

有两种解决办法:

  1. 把WinSock2.h写到windows.h之上,如下(不推荐):
#include<WinSock2.h>
#include<windows.h>
  1. 在使用到的地方定义WIN32精简宏(推荐):
#define WIN32_LEAN_AND_MEAN

#include<windows.h>
#include<WinSock2.h>

猜你喜欢

转载自blog.csdn.net/qq_16123279/article/details/87430462