radarsat1 / liblo

liblo is an implementation of the Open Sound Control protocol for POSIX systems
GNU Lesser General Public License v2.1
192 stars 60 forks source link

`winsock2.h` not included under MSYS2/MinGW #114

Closed Krasjet closed 2 years ago

Krasjet commented 3 years ago

The WIN32 macro is not defined in gcc under MSYS2/MinGW, so compiling any program using liblo (the version in MSYS2 repository) produces an error.

In file included from C:/msys64/mingw64/include/lo/lo.h:28,
                 from test.c:7:
C:/msys64/mingw64/include/lo/lo_endian.h:27:10: fatal error: netinet/in.h: No such file or directory
   27 | #include <netinet/in.h>
      |          ^~~~~~
compilation terminated.

Adding the

#include <winsock2.h>

header fixes the problem.

The _WIN32 macro should be preferred over WIN32. _WIN32 is defined by compilers on Windows, so MSVC, gcc, etc. all support this flag, but WIN32 is defined by the user or SDK (visual studio). It is not defined by gcc on Windows.

carlo-bramini commented 2 years ago

After committing PR #119, I think that this issue can be closed.