bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dirfd in C++ mode


From: Bruno Haible
Subject: Re: dirfd in C++ mode
Date: Sat, 4 Sep 2010 13:38:01 +0200
User-agent: KMail/1.9.9

Hi,

Jarno Rajahalme wrote:
> Apparently this was not the case on OSX (my case) or FreeBSD (see 
> http://savannah.gnu.org/bugs/?30721).
> 
> I get a compiler error:
> 
> In file included from sysdir.h:34:0,
>                  from dir-ops.cc:34:
> ../libgnu/dirent.h:380:1: error: '::dirfd' has not been declared
> 
> This appeared since the changes to the lib/dirent.in.h
> 
> OSX declares dirfd as a macro

Thanks for the report. gnulib needs to turn the macro into a function in
this case. I'm applying this fix:


2010-09-04  Bruno Haible  <address@hidden>

        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 <address@hidden>.

--- lib/dirent.in.h.orig        Sat Sep  4 13:32:48 2010
+++ lib/dirent.in.h     Sat Sep  4 13:31:03 2010
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]