Building a gnulib testdir of modules
  exclude glob
with option --with-c++-tests on CentOS 7, I see this compilation error:

g++ -DHAVE_CONFIG_H -DEXEEXT=\"\" -DEXEEXT=\"\" -I. -I../../gltests -I..  
-DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I../../gltests -I.. 
-I../../gltests/.. -I../gllib -I../../gltests/../gllib -Wall 
-DCONTINUE_AFTER_ASSERT -Wno-error -Wno-error -g -O2 -MT test-fnmatch-h-c++.o 
-MD -MP -MF $depbase.Tpo -c -o test-fnmatch-h-c++.o 
../../gltests/test-fnmatch-h-c++.cc &&\
mv -f $depbase.Tpo $depbase.Po
In file included from ../../gltests/test-fnmatch-h-c++.cc:22:0:
../gllib/fnmatch.h:651:1: error: 'fnmatch' was not declared in this scope
 _GL_CXXALIASWARN (fnmatch);
 ^
../gllib/fnmatch.h:651:1: note: suggested alternative:
../gllib/fnmatch.h:638:1: note:   'gnulib::fnmatch'
 _GL_CXXALIAS_RPL (fnmatch, int,
 ^
../gllib/fnmatch.h:651:27: error: invalid type in declaration before ';' token
 _GL_CXXALIASWARN (fnmatch);
                           ^
make[4]: *** [test-fnmatch-h-c++.o] Error 1


This patch fixes it.


2026-06-26  Bruno Haible  <[email protected]>

        fnmatch: Fix syntax error in C++ mode on CentOS 7.
        * lib/fnmatch.in.h (fnmatch): Provide declaration of overridden fnmatch
        function, needed for _GL_CXXALIASWARN.

diff --git a/lib/fnmatch.in.h b/lib/fnmatch.in.h
index 68085404ed..ef1ddf1ef8 100644
--- a/lib/fnmatch.in.h
+++ b/lib/fnmatch.in.h
@@ -81,6 +81,14 @@
 /* Match NAME against the file name pattern PATTERN,
    returning zero if it matches, FNM_NOMATCH if not.  */
 # if @REPLACE_FNMATCH@
+/* Because we haven't included the system's <fnmatch.h> (see above),
+   we need to state the system's 'fnmatch' declaration.  This is necessary
+   for the _GL_CXXALIASWARN invocation below.  */
+#  if @HAVE_FNMATCH@
+_GL_FUNCDECL_SYS (fnmatch, int,
+                  (const char *pattern, const char *name, int flags),
+                  _GL_ARG_NONNULL ((1, 2)));
+#  endif
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define fnmatch rpl_fnmatch
 #  endif




Reply via email to