GCC includes mingw-w64's stdarg.h before its own (include_next), and
this copy, which defines _STDARG_H, makes GCC skip its own definitions.
It defined only the two-argument va_start, so C23 and C++26 code using
va_start(ap) failed with "macro 'va_start' requires 2 arguments".
Define va_start as GCC 15 and later do in these modes, when the
compiler has __builtin_c23_va_start, and __STDC_VERSION_STDARG_H__.
---
mingw-w64-headers/crt/stdarg.h | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/mingw-w64-headers/crt/stdarg.h b/mingw-w64-headers/crt/stdarg.h
index 2ff5000a..94965ae0 100644
--- a/mingw-w64-headers/crt/stdarg.h
+++ b/mingw-w64-headers/crt/stdarg.h
@@ -49,7 +49,19 @@ typedef __builtin_va_list __gnuc_va_list;
if this invocation was from the user program. */
#ifdef _STDARG_H
+/* C23 and C++26: va_start with one argument, as in GCC's own stdarg.h,
+ which GCC includes after this one. Older GCCs lack the builtin. */
+#if ((defined __STDC_VERSION__ && __STDC_VERSION__ > 201710L) \
+ || (defined __cplusplus && __cplusplus >= 202400L)) \
+ && defined __has_builtin
+#if __has_builtin (__builtin_c23_va_start)
+#define va_start(...) __builtin_c23_va_start(__VA_ARGS__)
+#define __STDC_VERSION_STDARG_H__ 202311L
+#endif
+#endif
+#ifndef va_start
#define va_start(v,l) __builtin_va_start(v,l)
+#endif
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L ||
defined(__GXX_EXPERIMENTAL_CXX0X__)
--
2.56.0.windows.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public