sys_stat: Fix C++ test error on mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 10:55:17 +0000 (12:55 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 3 Apr 2010 10:55:17 +0000 (12:55 +0200)
ChangeLog
build-aux/c++defs.h
lib/sys_stat.in.h

index 26a5c55..1447063 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2010-04-03  Bruno Haible  <bruno@clisp.org>
 
+       sys_stat: Fix C++ test error on mingw.
+       * build-aux/c++defs.h (_GL_CXXALIAS_RPL_CAST_1): New macro.
+       * lib/sys_stat.in.h (lchmod): Use it instead of _GL_CXXALIAS_RPL_1.
+
+2010-04-03  Bruno Haible  <bruno@clisp.org>
+
        pty: Update doc.
        * doc/glibc-headers/pty.texi: Mention changes done since 2010-03-18.
 
index 7fbdd96..590e65a 100644 (file)
     _GL_EXTERN_C int _gl_cxxalias_dummy
 #endif
 
+/* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
+   is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
+   except that the C function rpl_func may have a slightly different
+   declaration.  A cast is used to silence the "invalid conversion" error
+   that would otherwise occur.  */
+#if defined __cplusplus && defined GNULIB_NAMESPACE
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+    namespace GNULIB_NAMESPACE                                     \
+    {                                                              \
+      rettype (*const func) parameters =                           \
+        reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
+    }                                                              \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#else
+# define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
+    _GL_EXTERN_C int _gl_cxxalias_dummy
+#endif
+
 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
    declares a C++ alias called GNULIB_NAMESPACE::func
    that redirects to the system provided function func, if GNULIB_NAMESPACE
index 89724c3..82792e4 100644 (file)
@@ -390,7 +390,10 @@ _GL_WARN_ON_USE (futimens, "futimens is not portable - "
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define lchmod chmod
 #  endif
-_GL_CXXALIAS_RPL_1 (lchmod, chmod, int, (const char *filename, mode_t mode));
+/* Need to cast, because on mingw, the second parameter of chmod is
+                                                int mode.  */
+_GL_CXXALIAS_RPL_CAST_1 (lchmod, chmod, int,
+                         (const char *filename, mode_t mode));
 # else
 #  if 0 /* assume already declared */
 _GL_FUNCDECL_SYS (lchmod, int, (const char *filename, mode_t mode)