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 3f55b0b0deb71e5de8a0f91f56c07eb006c4d689..0d0d9f0c81964f69b9ef30d72194ba605e9cd44c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
index 8414f2636357b3f9190e8dbeacc6a89f57ac817b..afcad9c7a89a4b5517e16ababb7345a2114fc96a 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