eclipse-iceoryx / iceoryx

Eclipse iceoryx™ - true zero-copy inter-process-communication
https://iceoryx.io
Apache License 2.0
1.68k stars 393 forks source link

[Visual Studio 2022] error C2011: 'sockaddr': 'struct' type redefinition #2171

Closed afpgit closed 9 months ago

afpgit commented 9 months ago

Required information

Operating system: Windows 11 x64

Compiler version: Visual Studio 2022

Eclipse iceoryx version: v2.0.3

Observed result or behaviour: I am developing a cross platform application and would like to integrate iceoryx into my app. I have no problem in linux but I get many errors such as the following when I am compiling the same source codes using Visual Studio 2022:

C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\ws2def.h(240): error C2011: 'sockaddr': 'struct' type redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winsock.h(482): note: see declaration of 'sockaddr'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\ws2def.h(442): error C2143: syntax error: missing '}' before 'constant'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\ws2def.h(442): error C2059: syntax error: 'constant'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\ws2def.h(496): error C2143: syntax error: missing ';' before '}'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\shared\ws2def.h(638): error C2011: 'sockaddr_in': 'struct' type redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winsock.h(309): note: see declaration of 'sockaddr_in'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winsock2.h(136): error C2011: 'fd_set': 'struct' type redefinition
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winsock.h(65): note: see declaration of 'fd_set'

I compiled using /P and noticed winsock.h is included in my app. Is there any way to get around this issue in Windows?

elBoberido commented 9 months ago

That's weird. We only define sockaddr_un on Windows. Are you able to switch to winsock2.h? If not, maybe you can try some of the solutions proposed in https://stackoverflow.com/a/8294669