Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socklen_t already defined on mingw32-w32api-dev 5.3 #302

Open
DarkWiiPlayer opened this issue Mar 29, 2020 · 4 comments
Open

socklen_t already defined on mingw32-w32api-dev 5.3 #302

DarkWiiPlayer opened this issue Mar 29, 2020 · 4 comments
Labels

Comments

@DarkWiiPlayer
Copy link

While trying to install luasocket on a fairly new windows installation, I started getting the following error:

In file included from src/socket.h:18,
                 from src/inet.h:18,
                 from src/luasocket.c:30:
src/wsocket.h:14:13: error: conflicting types for 'socklen_t'
   14 | typedef int socklen_t;
      |             ^~~~~~~~~
In file included from src/wsocket.h:12,
                 from src/socket.h:18,
                 from src/inet.h:18,
                 from src/luasocket.c:30:
c:\mingw\include\ws2tcpip.h:399:22: note: previous declaration of 'socklen_t' was here
  399 | typedef unsigned int socklen_t;
      |                      ^~~~~~~~~

After digging through files for a few hours (honestly, having no idea what I was doing, as I don't know and don't care much about mingw or windows in general), I found that there was apparently an update that adds this type definition to the header file.

From what I can tell, the typedefs should be mostly compatible (int vs. unsigned int). Assuming the value can't be negative, which sounds reasonable, given the type name.

The commit that introduced the changes in the git repo:

commit a45cb9690d6298067a8cf9e5d69b9f006833034d
Author: Keith Marshall <keith@users.osdn.me>
Date:   Mon Jan 20 18:03:57 2020 +0000

The LuaSec module seems to have the exact same problem.

@DarkWiiPlayer
Copy link
Author

As a quick fix, adding the following at the end of the rockspec works:

build.patches = {
['Fix mingw API change'] = [[
--- old/src/wsocket.h       2020-03-29 12:11:42.904053000 +0200
+++ new/src/wsocket.h       2020-03-29 12:10:06.829148800 +0200
@@ -11,7 +11,7 @@
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
-typedef int socklen_t;
+//typedef int socklen_t;
 typedef SOCKADDR_STORAGE t_sockaddr_storage;
 typedef SOCKET t_socket;
 typedef t_socket *p_socket;]]
}

@DarkWiiPlayer
Copy link
Author

DarkWiiPlayer commented Mar 30, 2020

I just dug through the mingw project again and found that the typedef isn't new, but it used to be just int in the past and now changed to unsigned int

EDIT: Given that this was always defined, is it even necessary to have it again in luasocket, or should the typedef just be removed altogether?

@limjiregister
Copy link

Nobody know how to fix this issue?

@DarkWiiPlayer
Copy link
Author

@limjiregister there's literally a patch in one of my previous comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants