wsServer icon indicating copy to clipboard operation
wsServer copied to clipboard

[bug] Unable to build with github msys action

Open caiiiycuk opened this issue 1 year ago • 2 comments

Description

I have following action configuration:

    - uses: msys2/setup-msys2@v2
      with:
          msystem: mingw64

And trying to build wsServer. It fails because of this:

ws.c:1778:71: error: passing argument 4 of 'setsockopt' from incompatible pointer type [-Wincompatible-pointer-types]
 1778 |                         setsockopt(new_sock, SOL_SOCKET, SO_SNDTIMEO, &time,
      |                                                                       ^~~~~
      |                                                                       |
      |                                                                       struct timeval *

source code link.

I don't know the reason but problematic parameter defined as const char* in mingw headers:

  WINSOCK_API_LINKAGE int WSAAPI setsockopt(SOCKET s,int level,int optname,const char *optval,int optlen);

I can bypass this by changing error level to warning, but I think it's good to fix. Other than this wsServer works fine on windows! Thank you!

caiiiycuk avatar Aug 30 '24 14:08 caiiiycuk

Quick workaround, just defined this in cmake:

    add_compile_options(-Wno-incompatible-pointer-types)

caiiiycuk avatar Aug 30 '24 14:08 caiiiycuk

Hi @caiiiycuk, The parameter in question is a const char*, but it can also accept other pointer types, such as struct timeval*. However, it appears that this generates a warning on Windows builds. This issue was addressed in commit 0d09382, as there’s no harm in casting to char* and void* since they are the only pointer types that are safe to cast.

Theldus avatar Sep 02 '24 01:09 Theldus