On FreeBSD 12, in C++ mode, the getrandom() function is declared with C++ linkage. This leads to a compilation error in test-sys_random-c++:
In file included from ../../gltests/test-sys_random-c++.cc:22: ../gllib/sys/random.h:594:19: error: declaration of 'getrandom' has a different language linkage _GL_CXXALIASWARN (getrandom); ^ /usr/include/sys/random.h:160:9: note: previous declaration is here ssize_t getrandom(void *buf, size_t buflen, unsigned int flags); ^ This patch fixes it. 2022-09-02 Bruno Haible <br...@clisp.org> getrandom: Fix compilation error in C++ mode on FreeBSD 12. * lib/sys_random.in.h (getrandom): Enable the C++ alias warning only on glibc ≥ 2.25 systems. diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h index e730e6139f..c91bcd2cd0 100644 --- a/lib/sys_random.in.h +++ b/lib/sys_random.in.h @@ -84,7 +84,9 @@ _GL_FUNCDECL_SYS (getrandom, ssize_t, _GL_CXXALIAS_SYS (getrandom, ssize_t, (void *buffer, size_t length, unsigned int flags)); # endif +# if __GLIBC__ + (__GLIBC_MINOR__ >= 25) > 2 _GL_CXXALIASWARN (getrandom); +# endif #elif defined GNULIB_POSIXCHECK # undef getrandom # if HAVE_RAW_DECL_GETRANDOM