GNOME Bugzilla – Bug 320930
Incorrect socklen_t test results
Last modified: 2005-11-11 23:28:37 UTC
Version details: 2.8.0.5 (also CVS HEAD) Distribution/Version: 10.3 and 10.4 During the ./configure test added in response to bug #79373, I get: checking for socklen_t... no and config.log says: configure:22644: checking for socklen_t configure:22668: gcc -c -g -O2 conftest.c >&5 conftest.c: In function `main': conftest.c:62: error: `socklen_t' undeclared (first use in this function) conftest.c:62: error: (Each undeclared identifier is reported only once conftest.c:62: error: for each function it appears in.) conftest.c:62: error: parse error before ')' token configure:22674: $? = 1 In fact I *do* have socklen_t, but it is declared in <sys/socket.h>, which is not #included by the config test. This means I get /* Define to `size_t' if <sys/types.h> does not define. */ #define socklen_t size_t which may not be the correct typedef. Looking at the source, socklen_t is used in daemon/gdm-net.c *after* a sys/socket.h is #included, which is why having the test fail is a problem. A quick fix might be to enhance the current AC_CHECK_TYPE(socklen_t,size_t) test (NB: that's a deprecated syntax anyway) to #include the header I need and that is assumed to exist on all other machines as well? The following works for me, not sure it doesn't break others for whom the current does work (i.e., have socklen_t but the two #includes I give aren't sufficient and/or don't compile): AC_CHECK_TYPE(socklen_t,,AC_DEFINE(socklen_t,size_t,Compatibility type), [ #include <sys/types.h> #include <sys/socket.h> ]) OTOH, instead of trying to design a configure test that has to devine the #include set that might be used, why not scrap the test altogether and just put #ifndef socklen_t #define socklen_t size_t #endif in daemon/gdm-net.c?
I'd prefer not to hack socklen_t by just #defining it in daemon/gdm-net.c if it isn't found. What would be nice would be to do the following: 1) Fix the current AC_CHECK_TYPE macro so it isn't using the deprecated syntax. 2) If that fails, use AC_COMPILE_IFELSE to try and compile a little c program that just includes <sys/socket.h>. If that passes, it can set a macro that will cause the #include <sys/socket.h> to be added to daemon/gdm-net.c Is this reasonable? Could you provide a patch? I'm also open to discussion if you think this isn't a good way to go. It just seems better to rely on the header files to define the sizes of things rather than trying to hack it. While it might fix the problem on your platform, it might cause problems on other platforms.
Yeah, I've got a nonstandard-for-gnome platform...hacks are Generally Bad Things:) Here's more info about the obsolete autoconf stuff: http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_node/autoconf_154.html But anyway, seems like the simplest nonhackish enhancement for the current implementation is simply to have the AC_CHECK_TYPE for socklen_t do an #include sys/socket.h, if such a header file exists, as part of its conftest.c? If you pass some #includes in the fourth parameter of the new AC_CHECK_TYPE syntax, they replace the default set that is used for conftest, so just pass "defaults + maybe sys/socket.h".
Created attachment 54454 [details] [review] Add #include <sys/socket.h> (if it exists) to socklen_t test.
Fixed in CVS head and 2.12 branch. What platform does this fix the configure for, by the way? Thanks for the patch, looks good.
I'm on Mac OS X. The underlying darwin kernel is substantially based on some *BSD flavors, and the definition of socklen_t being in <sys/socket.h> also appears in FreeBSD.