+2025-10-13 Bruno Haible <bruno@clisp.org>
+
+ getline: Fix compilation error in C++ mode (regression 2025-10-10).
+ * lib/stdio.in.h (getdelim): On glibc, define __getdelim instead of
+ rpl_getdelim.
+ (getline): In C++ mode, define getline as an inline function instead of
+ as a macro.
+ * lib/getdelim.c (getdelim): On glibc, don't test whether fp is NULL.
+
2025-10-12 Bruno Haible <bruno@clisp.org>
stdcountof-h tests: Fix link error on MSVC 14 (regression 2025-06-07).
# undef getdelim
# define getdelim rpl_getdelim
# endif
+# if __GLIBC__ >= 2
+/* Arrange for the inline definition of getline() in <bits/stdio.h>
+ to call our getdelim() override. */
+# define rpl_getdelim __getdelim
+# endif
_GL_FUNCDECL_RPL (getdelim, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
int delimiter,
Return the number of bytes read and stored at *LINEPTR (not including the
NUL terminator), or -1 on error or EOF. */
# if @REPLACE_GETLINE@
-# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-# undef getline
-# define getline rpl_getline
-# endif
_GL_FUNCDECL_RPL (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
FILE *restrict stream),
_GL_ARG_NONNULL ((1, 2, 3)) _GL_ATTRIBUTE_NODISCARD);
+# if defined __cplusplus
+/* The C++ standard library defines std::basic_istream::getline in <istream>
+ or <string>. */
+# if !(__GLIBC__ >= 2)
+extern "C" {
+inline ssize_t
+getline (char **restrict lineptr, size_t *restrict linesize,
+ FILE *restrict stream)
+{
+ return rpl_getline (lineptr, linesize, stream);
+}
+}
+# endif
+# else
+# undef getline
+# define getline rpl_getline
+# endif
_GL_CXXALIAS_RPL (getline, ssize_t,
(char **restrict lineptr, size_t *restrict linesize,
FILE *restrict stream));