From: Vadim Zeitlin Date: Thu, 11 Jul 2013 22:40:47 +0000 (+0000) Subject: Reconcile HAVE_VARIADIC_MACROS and wxHAS_VARIADIC_MACROS definitions. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/168d1f65c108f062c5d2ad975360d6ad0036e4c3 Reconcile HAVE_VARIADIC_MACROS and wxHAS_VARIADIC_MACROS definitions. The main user-visible effect of this change is that giving configure --disable-vararg-macros argument now really disables the use of variadic macros whereas it didn't disable them in wx/cpp.h before. It is, of course, also less confusing to not have two very similar but different symbols. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/configure b/configure index ccdb05d259..90f437239a 100755 --- a/configure +++ b/configure @@ -20816,6 +20816,9 @@ if test $wx_cv_have_variadic_macros = "yes"; then fi +else + $as_echo "#define wxNO_VARIADIC_MACROS 1" >>confdefs.h + fi LARGEFILE_CPPFLAGS= diff --git a/configure.in b/configure.in index e87b56cfcc..68edc08835 100644 --- a/configure.in +++ b/configure.in @@ -1767,6 +1767,8 @@ if test $wx_cv_have_variadic_macros = "yes"; then AC_DEFINE(HAVE_VARIADIC_MACROS) fi +else + AC_DEFINE(wxNO_VARIADIC_MACROS) fi dnl wxUSE_VARARG_MACROS == yes diff --git a/include/wx/cpp.h b/include/wx/cpp.h index 9fed106a76..f8b1d2ef58 100644 --- a/include/wx/cpp.h +++ b/include/wx/cpp.h @@ -124,16 +124,24 @@ #endif /* __WXFUNCTION__ already defined */ -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - (defined(__cplusplus) && __cplusplus >= 201103L) - #define wxHAS_VARIADIC_MACROS -#elif defined(__GNUC__) && __GNUC__ >= 3 - #define wxHAS_VARIADIC_MACROS -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - #define wxHAS_VARIADIC_MACROS -#endif +/* Auto-detect variadic macros support unless explicitly disabled. */ +#if !defined(HAVE_VARIADIC_MACROS) && !defined(wxNO_VARIADIC_MACROS) + /* Any C99 or C++11 compiler should have them. */ + #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) + #define HAVE_VARIADIC_MACROS + #elif defined(__GNUC__) && __GNUC__ >= 3 + #define HAVE_VARIADIC_MACROS + #elif wxCHECK_VISUALC_VERSION(8) + #define HAVE_VARIADIC_MACROS + #elif wxCHECK_WATCOM_VERSION(1,2) + #define HAVE_VARIADIC_MACROS + #endif +#endif /* !HAVE_VARIADIC_MACROS */ + + -#ifdef wxHAS_VARIADIC_MACROS +#ifdef HAVE_VARIADIC_MACROS /* wxCALL_FOR_EACH(what, ...) calls the macro from its first argument, what(pos, x), for every remaining argument 'x', with 'pos' being its 1-based index in @@ -172,7 +180,7 @@ #else #define wxCALL_FOR_EACH Error_wx_CALL_FOR_EACH_requires_variadic_macros_support -#endif /* wxHAS_VARIADIC_MACROS */ +#endif /* HAVE_VARIADIC_MACROS */ #endif /* _WX_CPP_H_ */ diff --git a/include/wx/defs.h b/include/wx/defs.h index c9648e8bc8..26bbf9721c 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -425,17 +425,6 @@ typedef short int WXTYPE; #endif /* va_copy/!va_copy */ #endif /* wxVaCopy */ -#ifndef HAVE_VARIADIC_MACROS - #if wxCHECK_WATCOM_VERSION(1,2) - #define HAVE_VARIADIC_MACROS - #endif - - #if wxCHECK_VISUALC_VERSION(9) - #define HAVE_VARIADIC_MACROS - #endif -#endif /* HAVE_VARIADIC_MACROS */ - - #ifndef HAVE_WOSTREAM /* Mingw <= 3.4 and all versions of Cygwin don't have std::wostream diff --git a/include/wx/testing.h b/include/wx/testing.h index dc1bd5ec33..99d375b0ae 100644 --- a/include/wx/testing.h +++ b/include/wx/testing.h @@ -337,7 +337,7 @@ private: wxExpectModal<> for your dialog type and implement its OnInvoked() method. */ -#ifdef wxHAS_VARIADIC_MACROS +#ifdef HAVE_VARIADIC_MACROS #define wxTEST_DIALOG(codeToRun, ...) \ { \ wxTEST_DIALOG_HOOK_CLASS wx_hook; \ @@ -345,7 +345,7 @@ private: codeToRun; \ wx_hook.CheckUnmetExpectations(); \ } -#endif /* wxHAS_VARIADIC_MACROS */ +#endif /* HAVE_VARIADIC_MACROS */ #endif // !WXBUILDING diff --git a/setup.h.in b/setup.h.in index 75588db311..8aaf1f5f18 100644 --- a/setup.h.in +++ b/setup.h.in @@ -711,6 +711,12 @@ */ #undef HAVE_VARIADIC_MACROS +/* + * Define if you don't want variadic macros to be used even if they are + * supported by the compiler. + */ +#undef wxNO_VARIADIC_MACROS + /* * Define if your compiler has std::wstring */ diff --git a/tests/controls/dialogtest.cpp b/tests/controls/dialogtest.cpp index 12f5833181..d4780f15c5 100644 --- a/tests/controls/dialogtest.cpp +++ b/tests/controls/dialogtest.cpp @@ -15,7 +15,7 @@ #include "wx/testing.h" -#ifdef wxHAS_VARIADIC_MACROS +#ifdef HAVE_VARIADIC_MACROS #include "wx/msgdlg.h" #include "wx/filedlg.h" @@ -122,4 +122,4 @@ void ModalDialogsTestCase::CustomDialog() CPPUNIT_ASSERT_EQUAL( 42, dlg.m_value ); } -#endif // wxHAS_VARIADIC_MACROS +#endif // HAVE_VARIADIC_MACROS