We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1131

Summary: socklen_t compilation breakage
Product: SDL_net Reporter: Ozkan Sezer <sezeroz>
Component: miscAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P2    
Version: unspecified   
Hardware: x86   
OS: Linux   

Description Ozkan Sezer 2011-02-17 19:38:25 UTC
The fix for bug #872 broke compilation by defining socklen_t depending on some _SOCKLEN_T macro.  I don't know where that macro is defined in any SDK, but I at least know that it is not defined by glibc nor is it defined by windows.

I first intended to do something like the following:

--- a/SDLnetsys.h~
+++ b/SDLnetsys.h
@@ -48,6 +48,9 @@
 #ifdef _WIN64
 #include <winsock2.h>
 #include <ws2tcpip.h>
+# ifndef _SOCKLEN_T
+# define _SOCKLEN_T /* winsock2 has socklen_t */
+# endif
 #else
 #include <winsock.h>
 #endif /* W64 */

... but it doesn't handle glibc headers.  Not sure what the correct solution is.
Comment 1 Sam Lantinga 2011-02-17 20:53:31 UTC
Fixed, thanks.
Comment 2 Ozkan Sezer 2011-02-17 21:58:43 UTC
Hmm, windows with winsock/1.x still need a socklen_t definition. The following fixes it for all compilers.

diff -r fb5762c4b219 SDLnetsys.h
--- a/SDLnetsys.h
+++ b/SDLnetsys.h
@@ -50,6 +50,9 @@
 #include <ws2tcpip.h>
 #else
 #include <winsock.h>
+/* NOTE: windows socklen_t is signed
+ * and is defined only for winsock2. */
+typedef int socklen_t;
 #endif /* W64 */
 #else /* UNIX */
 #ifdef __OS2__
Comment 3 Sam Lantinga 2011-02-17 23:45:39 UTC
Got it, thanks!