changeset 13627:d268b353aecf

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>.
author Bruno Haible <bruno@clisp.org>
date Sat, 04 Sep 2010 13:35:19 +0200
parents af42f5b6232d
children b8b731ae72a8
files ChangeLog lib/dirent.in.h
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -60,6 +60,12 @@
 _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