From 8fa53e0eee8b01adb47b0ea0833e4c5fbef750cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 2 Oct 2004 18:33:34 +0000 Subject: [PATCH] added tests for va_copy and va_list git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29605 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure.in | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.h.in | 10 +++++++++ setup.h_vms | 10 +++++++++ 3 files changed, 79 insertions(+) diff --git a/configure.in b/configure.in index a3670e48e4..c5a8c386ce 100644 --- a/configure.in +++ b/configure.in @@ -1713,6 +1713,65 @@ AC_CACHE_CHECK([size of wchar_t], wx_cv_sizeof_wchar_t, AC_DEFINE_UNQUOTED(SIZEOF_WCHAR_T, $wx_cv_sizeof_wchar_t) +dnl checks needed to define wxVaCopy +AC_CACHE_CHECK([for va_copy], + wx_cv_func_va_copy, + [ + AC_COMPILE_IFELSE([ + #include + void foo(char *f, ...) + { + va_list ap1, ap2; + va_start(ap1, f); + va_copy(ap2, ap1); + va_end(ap2); + va_end(ap1); + }], + wx_cv_func_va_copy=yes, + wx_cv_func_va_copy=no + ) + ] +) + +if test $wx_cv_func_va_copy = "yes"; then + AC_DEFINE(HAVE_VA_COPY) +else + dnl try to understand how can we copy va_lists + AC_CACHE_CHECK([if va_list can be copied by value], + wx_cv_type_va_list_lvalue, + [ + AC_RUN_IFELSE([ + #include + int foo(char *f, ...) + { + va_list ap1, ap2; + va_start(ap1, f); + ap2 = ap1; + if ( va_arg(ap1, int) != 17 || va_arg(ap2, int) != 17 ) + return 1; + va_end(ap2); + va_end(ap1); + return 0; + } + int main() + { + return foo("hi", 17); + }], + wx_cv_type_va_list_lvalue=yes, + wx_cv_type_va_list_lvalue=no, + dnl assume most common case for cross-compiling... + wx_cv_type_va_list_lvalue=yes + ) + ] + ) + + if test $wx_cv_type_va_list_lvalue != "yes"; then + dnl we suppose that the only thing which can't be copied like this + dnl are arrays... only experience will show whether this is really true + AC_DEFINE(VA_LIST_IS_ARRAY) + fi +fi + dnl check for large file support AC_SYS_LARGEFILE diff --git a/setup.h.in b/setup.h.in index 2115ca9cd8..7a21a972c9 100644 --- a/setup.h.in +++ b/setup.h.in @@ -173,6 +173,16 @@ */ #undef HAVE_STATIC_CAST +/* + * Define if your compiler has C99 va_copy + */ +#undef HAVE_VA_COPY + +/* + * Define if va_list type is an array + */ +#undef VA_LIST_IS_ARRAY + /* * Define if your compiler has std::wstring */ diff --git a/setup.h_vms b/setup.h_vms index b3e8f51567..6a4548d9d4 100644 --- a/setup.h_vms +++ b/setup.h_vms @@ -182,6 +182,16 @@ */ #define HAVE_STATIC_CAST 1 +/* + * Define if your compiler has C99 va_copy + */ +#undef HAVE_VA_COPY + +/* + * Define if va_list type is an array + */ +#undef VA_LIST_IS_ARRAY + /* * Define if your compiler has std::wstring */