[sane-devel] [PATCH v2 04/14] bldchn, checking for socklen_t more safe
On Tuesday 24 January 2012, Chris Bagwell wrote: On Mon, Jan 23, 2012 at 5:05 PM, Ruediger Meier sweet_f_a at gmx.de wrote: From: Ruediger Meier ruediger.meier at ga-group.nl Here I just want to fix conflicts for win32 systems. Generally I'd say that we should never #define socklen_t int within config.h. But this may decide somebody else. Note this patch may break the build on systems where socklen_t is available now but the right headers are not included yet. For example for win32 you need to add ?#ifdef HAVE_WS2TCPIP_H ?#include ws2tcpip.h ?#endif wherever socklen_t is used. --- ?configure ? ?| ? 14 +++--- ?configure.in | ? 12 ++-- ?2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 5da8db8..ba1df33 100755 --- a/configure +++ b/configure @@ -8257,12 +8257,20 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo $as_me:${as_lineno-$LINENO}: result: $have_long_long 5 $as_echo $have_long_long 6; } -{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t in sys/socket.h 5 -$as_echo_n checking for socklen_t in sys/socket.h... 6; } +{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t 5 +$as_echo_n checking for socklen_t... 6; } ?cat confdefs.h - _ACEOF conftest.$ac_ext ?/* end confdefs.h. ?*/ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif ?int ?main () diff --git a/configure.in b/configure.in index 060b8b6..b30dd92 100644 --- a/configure.in +++ b/configure.in @@ -232,9 +232,17 @@ have_long_long=no ?AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the long long type is available.]) have_long_long=yes) AC_MSG_RESULT($have_long_long) -AC_MSG_CHECKING([for socklen_t in sys/socket.h]) +AC_MSG_CHECKING([for socklen_t]) ?AC_TRY_COMPILE([ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif ?],[socklen_t len],AC_MSG_RESULT(yes), ?[AC_MSG_RESULT(no); AC_DEFINE(socklen_t,int, ?[Define socklen_t as \'int\' if necessary.])]) Since we are changing this, maybe we should change to more proper AC_CHECK_TYPES as well? That would require adding an #ifndef HAVE_SOCKELEN_T towards bottom of acinclude.m4 to match it. Fine, but then I'd go even a step further like I've mentioned in my commit message above - never _define_ such types in config.h. Better only using AC_CHECK_TYPES([socklen_t],,,[some includes]; This will replace #define socklen_t int by #undef HAVE_SOCKLEN_T Then we'd need to do #ifdef HAVE_SOCKLEN_T typedef int socklen_t; #endif wherever we use it or even better within a central header sane_types.h (maybe we have such header yet!?). In the long term I would do this for all types we are currently defining in config.h (*). Actually we are using socklen_t only within 5 files backend/dell1600n_net.c backend/net.c backend/pixma_bjnp.c frontend/saned.c sanei/sanei_udp.c So I'd like to post that AC_CHECK_TYPES([socklen_t]) patch separately from this win32/net series and you as a global maintainer may decide wheather and where to put the missing typedefs. (*) see also http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.68/html_node/Obsolete-Macros.html#Obsolete-Macros 18.4 Obsolete Macros ? Macro: AC_CHECK_TYPE (type, default) cu Rudi
[sane-devel] [PATCH v2 04/14] bldchn, checking for socklen_t more safe
From: Ruediger Meier ruediger.me...@ga-group.nl Here I just want to fix conflicts for win32 systems. Generally I'd say that we should never #define socklen_t int within config.h. But this may decide somebody else. Note this patch may break the build on systems where socklen_t is available now but the right headers are not included yet. For example for win32 you need to add #ifdef HAVE_WS2TCPIP_H #include ws2tcpip.h #endif wherever socklen_t is used. --- configure| 14 +++--- configure.in | 12 ++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 5da8db8..ba1df33 100755 --- a/configure +++ b/configure @@ -8257,12 +8257,20 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo $as_me:${as_lineno-$LINENO}: result: $have_long_long 5 $as_echo $have_long_long 6; } -{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t in sys/socket.h 5 -$as_echo_n checking for socklen_t in sys/socket.h... 6; } +{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t 5 +$as_echo_n checking for socklen_t... 6; } cat confdefs.h - _ACEOF conftest.$ac_ext /* end confdefs.h. */ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif int main () diff --git a/configure.in b/configure.in index 060b8b6..b30dd92 100644 --- a/configure.in +++ b/configure.in @@ -232,9 +232,17 @@ have_long_long=no AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the long long type is available.]) have_long_long=yes) AC_MSG_RESULT($have_long_long) -AC_MSG_CHECKING([for socklen_t in sys/socket.h]) +AC_MSG_CHECKING([for socklen_t]) AC_TRY_COMPILE([ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif ],[socklen_t len],AC_MSG_RESULT(yes), [AC_MSG_RESULT(no); AC_DEFINE(socklen_t,int, [Define socklen_t as \'int\' if necessary.])]) -- 1.7.6.1
[sane-devel] [PATCH v2 04/14] bldchn, checking for socklen_t more safe
On Mon, Jan 23, 2012 at 5:05 PM, Ruediger Meier sweet_f_a at gmx.de wrote: From: Ruediger Meier ruediger.meier at ga-group.nl Here I just want to fix conflicts for win32 systems. Generally I'd say that we should never #define socklen_t int within config.h. But this may decide somebody else. Note this patch may break the build on systems where socklen_t is available now but the right headers are not included yet. For example for win32 you need to add ?#ifdef HAVE_WS2TCPIP_H ?#include ws2tcpip.h ?#endif wherever socklen_t is used. --- ?configure ? ?| ? 14 +++--- ?configure.in | ? 12 ++-- ?2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 5da8db8..ba1df33 100755 --- a/configure +++ b/configure @@ -8257,12 +8257,20 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ?{ $as_echo $as_me:${as_lineno-$LINENO}: result: $have_long_long 5 ?$as_echo $have_long_long 6; } -{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t in sys/socket.h 5 -$as_echo_n checking for socklen_t in sys/socket.h... 6; } +{ $as_echo $as_me:${as_lineno-$LINENO}: checking for socklen_t 5 +$as_echo_n checking for socklen_t... 6; } ?cat confdefs.h - _ACEOF conftest.$ac_ext ?/* end confdefs.h. ?*/ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif ?int ?main () diff --git a/configure.in b/configure.in index 060b8b6..b30dd92 100644 --- a/configure.in +++ b/configure.in @@ -232,9 +232,17 @@ have_long_long=no ?AC_TRY_COMPILE([], [long long x; x = (long long)0;], AC_DEFINE(HAVE_LONG_LONG, 1, [Define if the long long type is available.]) have_long_long=yes) ?AC_MSG_RESULT($have_long_long) -AC_MSG_CHECKING([for socklen_t in sys/socket.h]) +AC_MSG_CHECKING([for socklen_t]) ?AC_TRY_COMPILE([ -#include sys/socket.h +#ifdef HAVE_SYS_SOCKET_H +# include sys/socket.h +#endif +#ifdef HAVE_WINSOCK2_H +# include winsock2.h +#endif +#ifdef HAVE_WS2TCPIP_H +# include ws2tcpip.h +#endif ?],[socklen_t len],AC_MSG_RESULT(yes), ?[AC_MSG_RESULT(no); AC_DEFINE(socklen_t,int, ?[Define socklen_t as \'int\' if necessary.])]) Since we are changing this, maybe we should change to more proper AC_CHECK_TYPES as well? That would require adding an #ifndef HAVE_SOCKELEN_T towards bottom of acinclude.m4 to match it. -- 1.7.6.1 -- sane-devel mailing list: sane-devel at lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel Unsubscribe: Send mail with subject unsubscribe your_password ? ? ? ? ? ? to sane-devel-request at lists.alioth.debian.org