bug-gnulib
[Top][All Lists]
Advanced

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

Re: strdup in C++ mode


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

> > 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

A similar compilation error would likely occur on systems which define
strdup as a macro (namely, glibc systems). I'm applying this fix:


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

        strdup: Fix compilation error in C++ mode.
        * lib/string.in.h (strdup): In C++ mode with GNULIB_NAMESPACE, undefine
        the macro.

--- lib/string.in.h.orig        Sat Sep  4 13:32:48 2010
+++ lib/string.in.h     Sat Sep  4 13:09:24 2010
@@ -311,6 +311,10 @@
 _GL_FUNCDECL_RPL (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (strdup, char *, (char const *__s));
 # else
+#  if defined __cplusplus && defined GNULIB_NAMESPACE && defined strdup
+    /* strdup exists as a function and as a macro.  Get rid of the macro.  */
+#   undef strdup
+#  endif
 #  if !(@HAVE_DECL_STRDUP@ || defined strdup)
 _GL_FUNCDECL_SYS (strdup, char *, (char const *__s) _GL_ARG_NONNULL ((1)));
 #  endif



reply via email to

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