Added configure test for const_cast<>(), and enabled it

for MSVC 5 and 6, and MinGW; use const_cast<>() in
wxConstCast if it is available.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19537 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-03-10 21:37:28 +00:00
parent 79e929e79e
commit 521196a26a
7 changed files with 886 additions and 763 deletions

View File

@@ -580,3 +580,21 @@ if test "$enable_largefile" != no; then
AC_MSG_RESULT($wx_largefile)
fi
])
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
dnl
AC_DEFUN([AC_CXX_CONST_CAST],
[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
ac_cv_cxx_const_cast,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_const_cast" = yes; then
AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
fi
])

18
aclocal.m4 vendored
View File

@@ -593,6 +593,24 @@ if test "$enable_largefile" != no; then
fi
])
dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
dnl
AC_DEFUN([AC_CXX_CONST_CAST],
[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
ac_cv_cxx_const_cast,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_const_cast" = yes; then
AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
fi
])
# Configure paths for GTK+
# Owen Taylor 1997-2001

1575
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1555,6 +1555,9 @@ WX_CPP_BOOL
dnl check whether C++ compiler supports explicit keyword
WX_CPP_EXPLICIT
dnl check whether C++ compiler supports C++ casts
AC_CXX_CONST_CAST
dnl ---------------------------------------------------------------------------
dnl Define search path for includes and libraries: all headers and libs will be
dnl looked for in all directories of this path

View File

@@ -222,8 +222,12 @@ typedef int wxWindowID;
// check for explicit keyword support
#ifndef HAVE_EXPLICIT
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
// VC++ 6.0 has explicit (what about the earlier versions?)
#if defined(__VISUALC__) && (__VISUALC__ >= 1100)
// VC++ 6.0 and 5.0 have explicit (what about the earlier versions?)
#define HAVE_EXPLICIT
#elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
&& wxCHECK_GCC_VERSION(2, 95)
// GCC 2.95 has explicit, what about earlier versions?
#define HAVE_EXPLICIT
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)
// BC++ 4.52 doesn't support explicit, CBuilder 1 does
@@ -240,6 +244,24 @@ typedef int wxWindowID;
#define wxEXPLICIT
#endif // HAVE_EXPLICIT/!HAVE_EXPLICIT
// check for static/const/reinterpret_cast<>()
#ifndef HAVE_STATIC_CAST
#if defined(__VISUALC__) && (__VISUALC__ >= 1100)
// VC++ 6.0 and 5.0 have C++ casts (what about the earlier versions?)
#define HAVE_CXX_CASTS
#elif ( defined(__MINGW32__) || defined(__CYGWIN32__) ) \
&& wxCHECK_GCC_VERSION(2, 95)
// GCC 2.95 has C++ casts, what about earlier versions?
#define HAVE_CXX_CASTS
#endif
#endif // HAVE_STATIC_CAST
#ifdef HAVE_CXX_CASTS
#ifndef HAVE_CONST_CAST
#define HAVE_CONST_CAST
#endif
#endif // HAVE_CXX_CASTS
// ----------------------------------------------------------------------------
// portable calling conventions macros
// ----------------------------------------------------------------------------

View File

@@ -305,7 +305,11 @@ name##PluginSentinel m_pluginsentinel;
#define wxDynamicCastThis(className) \
(IsKindOf(&className::sm_class##className) ? (className *)(this) : (className *)0)
#ifdef HAVE_CONST_CAST
#define wxConstCast(obj, className) const_cast<className *>(obj)
#else
#define wxConstCast(obj, className) ((className *)(obj))
#endif
#ifdef __WXDEBUG__

View File

@@ -150,6 +150,11 @@
*/
#undef HAVE_EXPLICIT
/*
* Define if your compiler supports const_cast<>()
*/
#undef HAVE_CONST_CAST
/*
* Use regex support
*/