dirfd: Fix compilation error in C++ mode on MacOS X, *BSD, IRIX.
authorBruno Haible <bruno@clisp.org>
Sat, 4 Sep 2010 11:35:19 +0000 (13:35 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 4 Sep 2010 11:35:19 +0000 (13:35 +0200)
* lib/dirent.in.h (dirfd): In C++ mode with GNULIB_NAMESPACE, turn the
macro into a function.
Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>.

ChangeLog
lib/dirent.in.h

index 3f55b0b..0d0d9f0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2010-09-04  Bruno Haible  <bruno@clisp.org>
 
+       dirfd: Fix compilation error in C++ mode on MacOS X, *BSD, IRIX.
+       * lib/dirent.in.h (dirfd): In C++ mode with GNULIB_NAMESPACE, turn the
+       macro into a function.
+       Reported by Jarno Rajahalme <jarno.rajahalme@nsn.com>.
+
+2010-09-04  Bruno Haible  <bruno@clisp.org>
+
        Set PATH_SEPARATOR the same way autoconf does.
        * build-aux/relocatable.sh.in (func_find_curr_installdir): Determine
        the value of PATH_SEPARATOR the same way autoconf-generated configure
index 8414f26..afcad9c 100644 (file)
@@ -60,6 +60,12 @@ _GL_CXXALIASWARN (closedir);
 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
 # else
+#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
+    /* dirfd is defined as a macro and not as a function.
+       Turn it into a function and get rid of the macro.  */
+static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
+#   undef dirfd
+#  endif
 #  if !(@HAVE_DECL_DIRFD@ || defined dirfd)
 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
 #  endif