]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
error-h: Support multiple gnulib-tool invocations in the same package.
authorBruno Haible <bruno@clisp.org>
Tue, 28 Apr 2026 23:52:17 +0000 (01:52 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 28 Apr 2026 23:52:17 +0000 (01:52 +0200)
* lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line):
New macros.
(verror): Test GNULIB_defined_verror, for consistency with the idiom.
(verror_at_line): Test GNULIB_defined_verror_at_line, for consistency
with the idiom.

ChangeLog
lib/error.in.h

index ad6f701635608eb443dd023e21be49a5f0579bff..c38bc06df4fc8763ece74f1b023ecdcaab81a89f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-04-28  Bruno Haible  <bruno@clisp.org>
+
+       error-h: Support multiple gnulib-tool invocations in the same package.
+       * lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line):
+       New macros.
+       (verror): Test GNULIB_defined_verror, for consistency with the idiom.
+       (verror_at_line): Test GNULIB_defined_verror_at_line, for consistency
+       with the idiom.
+
 2026-04-28  Bruno Haible  <bruno@clisp.org>
 
        realloc-posix: Support multiple gnulib-tool invocations in a package.
index 95ed6d8312e3ad04553e1a7b7d33d360fc60fc5a..97bb96c74b14ca91d680568e662278bdf8233d15 100644 (file)
@@ -115,11 +115,12 @@ _GL_FUNCDECL_SYS (error, void,
 _GL_CXXALIAS_SYS (error, void,
                   (int __status, int __errnum, const char *__format, ...));
 # ifndef _GL_NO_INLINE_ERROR
-#  ifdef error
+#  if !GNULIB_defined_error
+#   ifdef error
 /* Only gcc ≥ 4.7 has __builtin_va_arg_pack.  */
-#   if _GL_GNUC_PREREQ (4, 7)
-#    pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wattributes"
+#    if _GL_GNUC_PREREQ (4, 7)
+#     pragma GCC diagnostic push
+#     pragma GCC diagnostic ignored "-Wattributes"
 _GL_ATTRIBUTE_MAYBE_UNUSED
 static void
 _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
@@ -128,14 +129,16 @@ _gl_inline_error (int __status, int __errnum, const char *__format, ...)
 {
   return error (__status, __errnum, __format, __builtin_va_arg_pack ());
 }
-#    pragma GCC diagnostic pop
-#    undef error
+#     pragma GCC diagnostic pop
+#     undef error
+#     define error(status, ...) \
+        _gl_error_call (_gl_inline_error, status, __VA_ARGS__)
+#    endif
+#   else
 #    define error(status, ...) \
-       _gl_error_call (_gl_inline_error, status, __VA_ARGS__)
+       _gl_error_call (error, status, __VA_ARGS__)
 #   endif
-#  else
-#   define error(status, ...) \
-      _gl_error_call (error, status, __VA_ARGS__)
+#   define GNULIB_defined_error 1
 #  endif
 # endif
 #endif
@@ -175,11 +178,12 @@ _GL_CXXALIAS_SYS (error_at_line, void,
                   (int __status, int __errnum, const char *__filename,
                    unsigned int __lineno, const char *__format, ...));
 # ifndef _GL_NO_INLINE_ERROR
-#  ifdef error_at_line
+#  if !GNULIB_defined_error_at_line
+#   ifdef error_at_line
 /* Only gcc ≥ 4.7 has __builtin_va_arg_pack.  */
-#   if _GL_GNUC_PREREQ (4, 7)
-#    pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wattributes"
+#    if _GL_GNUC_PREREQ (4, 7)
+#     pragma GCC diagnostic push
+#     pragma GCC diagnostic ignored "-Wattributes"
 _GL_ATTRIBUTE_MAYBE_UNUSED
 static void
 _GL_ATTRIBUTE_ALWAYS_INLINE _GL_ATTRIBUTE_COLD
@@ -190,14 +194,16 @@ _gl_inline_error_at_line (int __status, int __errnum, const char *__filename,
   return error_at_line (__status, __errnum, __filename, __lineno, __format,
                         __builtin_va_arg_pack ());
 }
-#    pragma GCC diagnostic pop
-#    undef error_at_line
+#     pragma GCC diagnostic pop
+#     undef error_at_line
+#     define error_at_line(status, ...) \
+        _gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__)
+#    endif
+#   else
 #    define error_at_line(status, ...) \
-       _gl_error_call (_gl_inline_error_at_line, status, __VA_ARGS__)
+       _gl_error_call (error_at_line, status, __VA_ARGS__)
 #   endif
-#  else
-#   define error_at_line(status, ...) \
-      _gl_error_call (error_at_line, status, __VA_ARGS__)
+#   define GNULIB_defined_error_at_line 1
 #  endif
 # endif
 #endif
@@ -214,7 +220,7 @@ extern void verror (int __status, int __errnum, const char *__format,
      _GL_ATTRIBUTE_COLD
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 3, 0));
 #ifndef _GL_NO_INLINE_ERROR
-# ifndef verror
+# if !GNULIB_defined_verror
 #  define verror(status, ...) \
      _gl_error_call (verror, status, __VA_ARGS__)
 #  define GNULIB_defined_verror 1
@@ -234,7 +240,7 @@ extern void verror_at_line (int __status, int __errnum, const char *__fname,
      _GL_ATTRIBUTE_COLD
      _GL_ATTRIBUTE_FORMAT ((_GL_ATTRIBUTE_SPEC_PRINTF_STANDARD, 5, 0));
 #ifdef _GL_NO_INLINE_ERROR
-# ifndef verror_at_line
+# if !GNULIB_defined_verror_at_line
 #  define verror_at_line(status, ...) \
      _gl_error_call (verror_at_line, status, __VA_ARGS__)
 #  define GNULIB_defined_verror_at_line 1