Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 19 Apr 2023 15:56:43 +0200
From: Jens Gustedt <>
Subject: [C23 divers headers 14/17] C23: allow va_start to receive only one

C23 allows functions that only have ... and no other
arguments. Therefore the second argument to va_start, that was not
useful anymore, has been removed. For backwards compatibility it is
still possible to provide such an argument and the va_start macro has
to be adapted such that it is able to cope with one or two arguments.

We take care of this by using the new __VA_OPT__ preprocessing
feature, for which we also construct a feature test on the fly.
 include/stdarg.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/stdarg.h b/include/stdarg.h
index 3256f805..38db6257 100644
--- a/include/stdarg.h
+++ b/include/stdarg.h
@@ -1,5 +1,5 @@
-#ifndef _STDARG_H
-#define _STDARG_H
+#define __STDC_VERSION_STDARG_H__ 202311L
 #ifdef __cplusplus
 extern "C" {
@@ -9,7 +9,10 @@ extern "C" {
 #include <bits/alltypes.h>
-#define va_start(v,l)   __builtin_va_start(v,l)
+#define va_start(...) __va_start1(__VA_ARGS__ , 0, )
+#define __va_start1(...) __va_start2(__VA_ARGS__)
+#define __va_start2(v, l, ...) __builtin_va_start(v, l)
 #define va_end(v)       __builtin_va_end(v)
 #define va_arg(v,l)     __builtin_va_arg(v,l)
 #define va_copy(d,s)    __builtin_va_copy(d,s)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.