From d9485c28ed42df3f1a418f446203c780b6e31e3a Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Sat, 6 Jun 2015 16:27:40 -0700 Subject: [PATCH] Fix for va_copy. --- upb/pb/textprinter.c | 6 +----- upb/upb.h | 4 +++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/upb/pb/textprinter.c b/upb/pb/textprinter.c index 269881b91b..4932468a3d 100644 --- a/upb/pb/textprinter.c +++ b/upb/pb/textprinter.c @@ -96,10 +96,6 @@ static int putescaped(upb_textprinter *p, const char *buf, size_t len, return 0; } -#ifdef __GNUC__ -#define va_copy(a, b) __va_copy(a, b) -#endif - bool putf(upb_textprinter *p, const char *fmt, ...) { va_list args; va_list args_copy; @@ -111,7 +107,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) { va_start(args, fmt); /* Run once to get the length of the string. */ - va_copy(args_copy, args); + _upb_va_copy(args_copy, args); len = _upb_vsnprintf(NULL, 0, fmt, args_copy); va_end(args_copy); diff --git a/upb/upb.h b/upb/upb.h index ad094f43d2..294b2fad75 100644 --- a/upb/upb.h +++ b/upb/upb.h @@ -52,12 +52,14 @@ #ifdef __GNUC__ #define _upb_snprintf __builtin_snprintf #define _upb_vsnprintf __builtin_vsnprintf +#define _upb_va_copy(a, b) __va_copy(a, b) #elif __STDC_VERSION__ >= 199901L /* C99 versions. */ #define _upb_snprintf snprintf #define _upb_vsnprintf vsnprintf +#define _upb_va_copy(a, b) va_copy(a, b) #else -#error Need implementations of [v]snprintf +#error Need implementations of [v]snprintf and va_copy #endif