0

Headers order below

#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>

All code was written and debugged in VS2019, and compiles there fine. But after migration appears classic problem of misordering winsockets headers. As that

error C2011: 'sockaddr' : 'struct' type redefinition

Anybody any suggestions, what is the cause ?

az0009990
  • 13
  • 4
  • This "as is" with Visual Studio 2022 should compile fine. Are you sure you're not hitting this instead: https://stackoverflow.com/questions/1372480/c-redefinition-header-files-winsock2-h – Simon Mourier Mar 14 '22 at 14:14
  • Headers included in one file in one place – az0009990 Mar 14 '22 at 16:39
  • 1
    you drop important information from error message - 1. where sockaddr was defined first time and 2. where is sockaddr redefined – RbMm Mar 14 '22 at 16:58
  • Please also show a [mcve]. – IInspectable Mar 15 '22 at 10:27
  • Looks like WIN32_LEAN_AND_MEAN broken.After commenting line #include , from windows.h project builds without errors. WTF ? What wrong with my Visual Studio, how to fix this issue? – az0009990 Mar 15 '22 at 19:14
  • `#include ` is still guarded for me behind an `#ifndef WIN32_LEAN_AND_MEAN` in my VS 2022 setup. What SDK version are you referencing? And can you please provide a [mcve] including the **full** error diagnostic? – IInspectable Mar 16 '22 at 12:26

0 Answers0