lpcware

Missing va_copy()

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by g_mocken on Tue Feb 03 06:24:10 MST 2015
Hi,

I am confused about va_copy()  (one of the macros in stdarg.h used for dealing with variadic function arguments):

It's defined as

#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#define va_copy(d,s)__builtin_va_copy(d,s)
#endif
#define __va_copy(d,s)__builtin_va_copy(d,s)
in tools/lib/gcc/arm-none-eabi/4.8.4/include/stdarg.h, but apparently the file tools/redlib/include/stdarg.h, which omits this definition, i.e. only defines
#define va_start(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)

is preferred - no matter what library (redlib or not) I use.

Using directly __builtin_va_copy() seems to work, but that's a quick and (possibly) dirty solution. What would be a safe and portable one?

Note that I am using C99.

G.

Outcomes