On Linux/riscv64 with musl libc, I see this compilation error in a testdir of
all of gnulib:

In file included from ../gllib/sys/select.h:131,
                 from /usr/include/sys/time.h:9,
                 from ../gllib/sys/time.h:46,
                 from ../gllib/sys/select.h:102,
                 from /usr/include/sys/types.h:71,
                 from ../gllib/sys/types.h:46,
                 from ../gllib/stdio.h:83,
                 from ../../gltests/test-stdio-c++.cc:22:
../gllib/stdio.h:1183:1: error: 'fpurge' was not declared in this scope; did 
you mean 'gnulib::fpurge'?
 1183 | _GL_CXXALIASWARN (fpurge);
      | ^~~~~~~~~~~~~~~~
../gllib/stdio.h:1176:1: note: 'gnulib::fpurge' declared here
 1176 | _GL_CXXALIAS_RPL (fpurge, int, (FILE *gl_stream));
      | ^~~~~~~~~~~~~~~~
make[4]: *** [Makefile:27581: test-stdio-c++.o] Error 1

The particular circumstance is that HAVE_FPURGE is 1 and REPLACE_FPURGE is 1
as well (because fpurge exists in libc but is not declared).

This patch fixes it.


2024-08-21  Bruno Haible  <br...@clisp.org>

        stdio: Fix compilation error in C++ mode on Linux/riscv64 with musl.
        * lib/stdio.in.h (fpurge): Disable _GL_CXXALIASWARN invocation on
        non-glibc systems.

diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index e693fd7d06..67277d5ffe 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -646,7 +646,9 @@ _GL_FUNCDECL_SYS (fpurge, int, (FILE *gl_stream), 
_GL_ARG_NONNULL ((1)));
 #  endif
 _GL_CXXALIAS_SYS (fpurge, int, (FILE *gl_stream));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fpurge);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fpurge
 # if HAVE_RAW_DECL_FPURGE




Reply via email to