03 VS project compilation error warning C4005: "AF_IPX": macro redefinition warning C4005: "AF_IPX": macro redefinition

Project scenario:

Problem Description:

There are some errors or warnings when compiling the project

warning C4005: “AF_IPX”: 宏重定义warning C4005: “AF_IPX”: 宏重定义

Cause Analysis:

It may be due to the redefinition caused by the <winsock.h> header file included in <windows.h>

solution:

  • method 1:

WIN32_LEAN_AND_MEANDefine the macro before including <windows.h> , as
follows:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
  • Method 2:

Right-click the project->C/C+±>Add preprocessorWIN32_LEAN_AND_MEAN

Guess you like

Origin blog.csdn.net/pointerz_zyz/article/details/128864283