From ca766534cff840792cf4614641048e17a3c22804 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 5 Sep 2006 14:21:08 +0000 Subject: [PATCH 1/1] use macros to completely remove wxLogTrace, wxLogDebug etc. in release build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41015 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 86 +++++++++++++++++++++++++++++++++++++++++++----- configure.in | 25 ++++++++++++++ include/wx/log.h | 17 +++++++--- setup.h.in | 5 +++ 4 files changed, 119 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 5b87adbb64..5bc99b4260 100755 --- a/configure +++ b/configure @@ -12156,7 +12156,7 @@ echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" +CFLAGS="$CFLAGS -g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then @@ -12628,7 +12628,7 @@ fi unset ac_cv_prog_cc_g ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" +CFLAGS="$CFLAGS -g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then @@ -13800,9 +13800,9 @@ if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then - CXXFLAGS="-g -O2" + CXXFLAGS="$CXXFLAGS -g -O2" else - CXXFLAGS="-g" + CXXFLAGS="$CXXFLAGS -g" fi else if test "$GXX" = yes; then @@ -14065,7 +14065,7 @@ fi unset ac_cv_prog_cc_g ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -CFLAGS="-g" +CFLAGS="$CFLAGS -g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then @@ -22058,6 +22058,76 @@ _ACEOF fi fi +echo "$as_me:$LINENO: checking whether the compiler supports variadic macros" >&5 +echo $ECHO_N "checking whether the compiler supports variadic macros... $ECHO_C" >&6 +if test "${wx_cv_have_variadic_macros+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #include + #define test(fmt, ...) printf(fmt, __VA_ARGS__) + +int +main () +{ + + test("%s %d %p", "test", 1, 0); + + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + wx_cv_have_variadic_macros=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +wx_cv_have_variadic_macros=no + +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext + + +fi +echo "$as_me:$LINENO: result: $wx_cv_have_variadic_macros" >&5 +echo "${ECHO_T}$wx_cv_have_variadic_macros" >&6 + +if test $wx_cv_have_variadic_macros = "yes"; then + cat >>confdefs.h <<\_ACEOF +#define HAVE_VARIADIC_MACROS 1 +_ACEOF + +fi + # Check whether --enable-largefile or --disable-largefile was given. if test "${enable_largefile+set}" = set; then enableval="$enable_largefile" @@ -34897,10 +34967,8 @@ if test "${wx_cv_func_snprintf_pos_params+set}" = set; then else if test "$cross_compiling" = yes; then - { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} + { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5 +echo "$as_me: error: internal error: not reached in cross-compile" >&2;} { (exit 1); exit 1; }; } else cat >conftest.$ac_ext <<_ACEOF diff --git a/configure.in b/configure.in index 0a6d9a5409..f9ebefe8ed 100644 --- a/configure.in +++ b/configure.in @@ -1931,6 +1931,31 @@ else fi fi +dnl Check if variadic macros (C99 feature) are supported: +AC_CACHE_CHECK( + [whether the compiler supports variadic macros], + [wx_cv_have_variadic_macros], + [ + AC_COMPILE_IFELSE( + AC_LANG_PROGRAM( + [ + #include + #define test(fmt, ...) printf(fmt, __VA_ARGS__) + ], + [ + test("%s %d %p", "test", 1, 0); + ] + ), + [wx_cv_have_variadic_macros=yes], + [wx_cv_have_variadic_macros=no] + ) + ] +) + +if test $wx_cv_have_variadic_macros = "yes"; then + AC_DEFINE(HAVE_VARIADIC_MACROS) +fi + dnl check for large file support AC_SYS_LARGEFILE diff --git a/include/wx/log.h b/include/wx/log.h index 0e548d2bbe..09c20bf71c 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -567,14 +567,21 @@ DECLARE_LOG_FUNCTION2(SysError, long, lErrCode); #else //!debug || !wxUSE_LOG // these functions do nothing in release builds + #define wxVLogDebug(fmt, valist) + #define wxVLogTrace(mask, fmt, valist) + + #ifdef HAVE_VARIADIC_MACROS + // unlike the inline functions below, this completely removes the + // wxLogXXX calls from the object file: + #define wxLogDebug(fmt, ...) + #define wxLogTrace(mask, fmt, ...) + #else // !HAVE_VARIADIC_MACROS // note that leaving out "fmt" in the vararg functions provokes a warning // from SGI CC: "the last argument of the varargs function is unnamed" - inline void wxVLogDebug(const wxChar *, va_list) { } inline void wxLogDebug(const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(wxTraceMask, const wxChar *, va_list) { } inline void wxLogTrace(wxTraceMask, const wxChar *fmt, ...) { wxUnusedVar(fmt); } - inline void wxVLogTrace(const wxChar *, const wxChar *, va_list) { } inline void wxLogTrace(const wxChar *, const wxChar *fmt, ...) { wxUnusedVar(fmt); } + #endif // HAVE_VARIADIC_MACROS/!HAVE_VARIADIC_MACROS #endif // debug/!debug // wxLogFatalError helper: show the (fatal) error to the user in a safe way, @@ -605,8 +612,8 @@ wxSafeShowMessage(const wxString& title, const wxString& text); #define wxLogLastError(api) wxLogApiError(api, wxSysErrorCode()) #else //!debug - inline void wxLogApiError(const wxChar *, long) { } - inline void wxLogLastError(const wxChar *) { } + #define wxLogApiError(api, err) + #define wxLogLastError(api) #endif //debug/!debug // wxCocoa has additiional trace masks diff --git a/setup.h.in b/setup.h.in index c6090c0bcb..1fc6de667b 100644 --- a/setup.h.in +++ b/setup.h.in @@ -567,6 +567,11 @@ */ #undef VA_LIST_IS_ARRAY +/* + * Define if the compiler supports variadic macros + */ +#undef HAVE_VARIADIC_MACROS + /* * Define if your compiler has std::wstring */ -- 2.45.2