Skip to content

Commit 4d93b6c

Browse files
committed
Check for va_copy declaration
ctx.c contains a workaround for systems without va_copy() support. Improve this workaround in the way which is described in the autoconf manual. Also check for va_copy declaration in configure time. Fixes #160.
1 parent 65b3a09 commit 4d93b6c

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ AC_ARG_ENABLE([cares],
3333

3434
AC_SEARCH_LIBS([socket], [network socket])
3535
AC_CHECK_FUNCS([snprintf vsnprintf])
36+
AC_CHECK_DECLS([va_copy], [], [], [#include <stdarg.h>])
3637

3738
if test "x$enable_tls" != xno; then
3839
PKG_CHECK_MODULES([openssl], [openssl],

src/ctx.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@
5050
#include "resolver.h"
5151
#include "util.h"
5252

53-
/* Workaround for visual studio without va_copy support. */
54-
#if defined(_MSC_VER) && _MSC_VER < 1800 || defined(__HAIKU__)
55-
#define va_copy(d, s) ((d) = (s))
53+
/* Workaround for systems without va_copy support. */
54+
#if defined(_MSC_VER) && _MSC_VER < 1800 || \
55+
!defined(_MSC_VER) && !defined(HAVE_DECL_VA_COPY)
56+
#define va_copy(d, s) (memcpy(&d, &s, sizeof(va_list)))
5657
#endif
5758

5859
/** Initialize the Strophe library.

0 commit comments

Comments
 (0)