Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C2011: 'sockaddr' : 'struct' type redefinition. see declaration of 'sockaddr' [duplicate]

I use Visual Studio 2012 and trying to get static library UDT get to work. Unfortunately, i cannot compile project that links UDT lib to itself, i get 159 strange errors about type or macro redefinitions in windows SDK headers.

c:\program files\windows kits\8.0\include\shared\ws2def.h(96): warning C4005: 'AF_IPX' : macro redefinition 2> c:\program files\windows kits\8.0\include\um\winsock.h(452) : see previous definition of 'AF_IPX' 2>c:\program files\windows kits\8.0\include\shared\ws2def.h(136): warning C4005: 'AF_MAX' : macro redefinition 2> c:\program files\windows kits\8.0\include\um\winsock.h(471) : see previous definition of 'AF_MAX' 2>c:\program files\windows kits\8.0\include\shared\ws2def.h(173): warning C4005: 'SO_DONTLINGER' : macro redefinition 2> c:\program files\windows kits\8.0\include\um\winsock.h(394) : see previous definition of 'SO_DONTLINGER' 2>c:\program files\windows kits\8.0\include\shared\ws2def.h(217): error C2011: 'sockaddr' : 'struct' type redefinition 2> c:\program files\windows kits\8.0\include\um\winsock.h(477) : see declaration of 'sockaddr'

Previously removed some code which was defining dllexport/dllimport for each UDT function:

#define UDT_API // no dllimport/export

I checked that library always use #ifdef to check if file is already included. And this error:

windows kits\8.0\include\um\ws2tcpip.h(703): error C3861: 'WSASetLastError': identifier not found

May reason be const keyword in that expression (somewhere inside udt):

UDT_API int bind(UDTSOCKET u, const struct sockaddr* name, int namelen);

What iam missing?

like image 485
Croll Avatar asked Dec 24 '22 17:12

Croll


1 Answers

If you include winsock.h and winsock2.h make sure that you include winsock2.h first. If the includes are not so obvious you can check cpp files in question if you compile them with /P and walk through the generated preprocessor output file.

like image 163
Werner Henze Avatar answered Dec 28 '22 10:12

Werner Henze