sys_select: Avoid #define replacements in C++ mode.
authorBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 00:33:25 +0000 (01:33 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 02:11:13 +0000 (03:11 +0100)
ChangeLog
lib/sys_select.in.h
modules/sys_select

index f7abd58..1281252 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+       sys_select: Avoid #define replacements in C++ mode.
+       * lib/sys_select.in.h: Include c++defs.h. Enable the function
+       definitions also when the system has a <sys/select.h>.
+       (select): In C++, define a namespaced alias symbol.
+       * modules/sys_select (Depends-on): Add c++defs.
+       (Makefile.am): Update sys/select.h rule.
+
        sys_ioctl: Avoid #define replacements in C++ mode.
        * lib/sys_ioctl.in.h: Include c++defs.h.
        (ioctl): In C++, define a namespaced alias symbol.
index b506e9f..ae2a3d2 100644 (file)
 #define _GL_SYS_SELECT_H
 
 #if !@HAVE_SYS_SELECT_H@ || @REPLACE_SELECT@
-
 /* A platform that lacks <sys/select.h>.  */
-
 # include <sys/socket.h>
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
-# ifdef __cplusplus
-extern "C" {
-# endif
 
-# if @GNULIB_SELECT@
-#  if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
+#if @GNULIB_SELECT@
+# if @HAVE_WINSOCK2_H@ || @REPLACE_SELECT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef select
 #   define select rpl_select
-extern int rpl_select (int, fd_set *, fd_set *, fd_set *, struct timeval *);
 #  endif
-# elif @HAVE_WINSOCK2_H@
-#  undef select
-#  define select select_used_without_requesting_gnulib_module_select
-# elif defined GNULIB_POSIXCHECK
-#  undef select
-#  if HAVE_RAW_DECL_SELECT
+_GL_FUNCDECL_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+_GL_CXXALIAS_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# else
+_GL_CXXALIAS_SYS (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# endif
+_GL_CXXALIASWARN (select);
+#elif @HAVE_WINSOCK2_H@
+# undef select
+# define select select_used_without_requesting_gnulib_module_select
+#elif defined GNULIB_POSIXCHECK
+# undef select
+# if HAVE_RAW_DECL_SELECT
 _GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
                  "use gnulib module select for portability");
-#  endif
-# endif
-
-# ifdef __cplusplus
-}
 # endif
-
 #endif
 
+
 #endif /* _GL_SYS_SELECT_H */
 #endif /* _GL_SYS_SELECT_H */
 #endif /* OSF/1 */
index 27d9a48..4f4d6d9 100644 (file)
@@ -7,6 +7,7 @@ m4/sys_select_h.m4
 
 Depends-on:
 include_next
+c++defs
 sys_socket
 sys_time
 warn-on-use
@@ -20,7 +21,7 @@ BUILT_SOURCES += sys/select.h
 
 # We need the following in order to create <sys/select.h> when the system
 # doesn't have one that works with the given compiler.
-sys/select.h: sys_select.in.h $(WARN_ON_USE_H)
+sys/select.h: sys_select.in.h $(CXXDEFS_H) $(WARN_ON_USE_H)
        $(AM_V_at)$(MKDIR_P) sys
        $(AM_V_GEN)rm -f $@-t $@ && \
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
@@ -31,6 +32,7 @@ sys/select.h: sys_select.in.h $(WARN_ON_USE_H)
              -e 's|@''GNULIB_SELECT''@|$(GNULIB_SELECT)|g' \
              -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
              -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
              -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
              < $(srcdir)/sys_select.in.h; \
        } > $@-t && \