Building a testdir on mingw 10.0, I see these compilation errors:
In file included from ../gllib/stdlib.h:52,
from
/usr/x86_64-w64-mingw32/sys-root/mingw/include/sec_api/stdlib_s.h:9,
from
/usr/x86_64-w64-mingw32/sys-root/mingw/include/stdlib.h:765,
from /usr/lib/gcc/x86_64-w64-mingw32/11/include/c++/cstdlib:75,
from ../../gltests/test-stdlib-c++2.cc:20:
../gllib/stdlib.h:1618:1: error: 'random' was not declared in this scope; did
you mean 'gnulib::random'?
1618 | _GL_CXXALIASWARN (random);
| ^~~~~~~~~~~~~~~~
../gllib/stdlib.h:1609:1: note: 'gnulib::random' declared here
1609 | _GL_CXXALIAS_RPL (random, long, (void));
| ^~~~~~~~~~~~~~~~
../gllib/stdlib.h:1643:1: error: 'srandom' was not declared in this scope; did
you mean 'gnulib::srandom'?
1643 | _GL_CXXALIASWARN (srandom);
| ^~~~~~~~~~~~~~~~
../gllib/stdlib.h:1634:1: note: 'gnulib::srandom' declared here
1634 | _GL_CXXALIAS_RPL (srandom, void, (unsigned int seed));
| ^~~~~~~~~~~~~~~~
make[4]: *** [Makefile:24099: test-stdlib-c++2.o] Error 1
This patch fixes it.
2023-04-19 Bruno Haible <[email protected]>
random: Fix compilation errors in C++ on mingw 10.
* lib/stdlib.in.h (random, srandom): Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index bccab0e2c3..1479a2b287 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1058,7 +1058,9 @@ _GL_FUNCDECL_SYS (random, long, (void));
int. */
_GL_CXXALIAS_SYS_CAST (random, long, (void));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (random);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef random
# if HAVE_RAW_DECL_RANDOM
@@ -1083,7 +1085,9 @@ _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
unsigned long seed. */
_GL_CXXALIAS_SYS_CAST (srandom, void, (unsigned int seed));
# endif
+# if __GLIBC__ >= 2
_GL_CXXALIASWARN (srandom);
+# endif
#elif defined GNULIB_POSIXCHECK
# undef srandom
# if HAVE_RAW_DECL_SRANDOM