bug-gnulib
[Top][All Lists]
Advanced

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

glob: fix failure in C++ mode


From: Bruno Haible
Subject: glob: fix failure in C++ mode
Date: Fri, 16 Mar 2018 10:40:17 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-112-generic; KDE/5.18.0; x86_64; ; )

$ ./gnulib-tool --create-testdir --dir=../testdir-glob --single-configure 
--with-c++-tests glob
produces a testdir that, when compiled on a glibc 2.23 system, produces errors:

depbase=`echo test-glob-c++.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
g++ -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 
-I. -I. -I.. -I./.. -I../gllib -I./../gllib    -MT test-glob-c++.o -MD -MP -MF 
$depbase.Tpo -c -o test-glob-c++.o test-glob-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:219:0,
                 from ../gllib/sys/types.h:28,
                 from ../gllib/sys/stat.h:41,
                 from ../gllib/glob.h:31,
                 from test-glob-c++.cc:22:
../gllib/glob.h:56:54: error: expected ',' or '...' before '__pattern'
 _GL_CXXALIAS_RPL (glob, int, (const char *_Restrict_ __pattern, int __flags,
                                                      ^
...
Makefile:3470: recipe for target 'test-glob-c++.o' failed
make[4]: *** [test-glob-c++.o] Error 1

This fixes it.


2018-03-15  Bruno Haible  <address@hidden>

        glob: Fix compilation error in C++ mode.
        * lib/glob.in.h (_Restrict_): Define, like in regex.h and spawn.in.h.

diff --git a/lib/glob.in.h b/lib/glob.in.h
index 4d71ef8..cc3f48c 100644
--- a/lib/glob.in.h
+++ b/lib/glob.in.h
@@ -33,6 +33,21 @@
 # define __USE_GNU    1
 #endif
 
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+   "restrict", and "configure" may have defined "restrict".
+   Other compilers use __restrict, __restrict__, and _Restrict, and
+   'configure' might #define 'restrict' to those words, so pick a
+   different name.  */
+#ifndef _Restrict_
+# if 199901L <= __STDC_VERSION__
+#  define _Restrict_ restrict
+# elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)
+#  define _Restrict_ __restrict
+# else
+#  define _Restrict_
+# endif
+#endif
+
 
 #define glob rpl_glob
 #define globfree rpl_globfree




reply via email to

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