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:
18
acinclude.m4
18
acinclude.m4
@@ -580,3 +580,21 @@ if test "$enable_largefile" != no; then
|
|||||||
AC_MSG_RESULT($wx_largefile)
|
AC_MSG_RESULT($wx_largefile)
|
||||||
fi
|
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
18
aclocal.m4
vendored
@@ -593,6 +593,24 @@ if test "$enable_largefile" != no; then
|
|||||||
fi
|
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+
|
# Configure paths for GTK+
|
||||||
# Owen Taylor 1997-2001
|
# Owen Taylor 1997-2001
|
||||||
|
|
||||||
|
@@ -1555,6 +1555,9 @@ WX_CPP_BOOL
|
|||||||
dnl check whether C++ compiler supports explicit keyword
|
dnl check whether C++ compiler supports explicit keyword
|
||||||
WX_CPP_EXPLICIT
|
WX_CPP_EXPLICIT
|
||||||
|
|
||||||
|
dnl check whether C++ compiler supports C++ casts
|
||||||
|
AC_CXX_CONST_CAST
|
||||||
|
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
dnl Define search path for includes and libraries: all headers and libs will be
|
dnl Define search path for includes and libraries: all headers and libs will be
|
||||||
dnl looked for in all directories of this path
|
dnl looked for in all directories of this path
|
||||||
|
@@ -222,8 +222,12 @@ typedef int wxWindowID;
|
|||||||
|
|
||||||
// check for explicit keyword support
|
// check for explicit keyword support
|
||||||
#ifndef HAVE_EXPLICIT
|
#ifndef HAVE_EXPLICIT
|
||||||
#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
|
#if defined(__VISUALC__) && (__VISUALC__ >= 1100)
|
||||||
// VC++ 6.0 has explicit (what about the earlier versions?)
|
// 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
|
#define HAVE_EXPLICIT
|
||||||
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)
|
#elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x0520)
|
||||||
// BC++ 4.52 doesn't support explicit, CBuilder 1 does
|
// BC++ 4.52 doesn't support explicit, CBuilder 1 does
|
||||||
@@ -240,6 +244,24 @@ typedef int wxWindowID;
|
|||||||
#define wxEXPLICIT
|
#define wxEXPLICIT
|
||||||
#endif // HAVE_EXPLICIT/!HAVE_EXPLICIT
|
#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
|
// portable calling conventions macros
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -305,7 +305,11 @@ name##PluginSentinel m_pluginsentinel;
|
|||||||
#define wxDynamicCastThis(className) \
|
#define wxDynamicCastThis(className) \
|
||||||
(IsKindOf(&className::sm_class##className) ? (className *)(this) : (className *)0)
|
(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))
|
#define wxConstCast(obj, className) ((className *)(obj))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
@@ -150,6 +150,11 @@
|
|||||||
*/
|
*/
|
||||||
#undef HAVE_EXPLICIT
|
#undef HAVE_EXPLICIT
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define if your compiler supports const_cast<>()
|
||||||
|
*/
|
||||||
|
#undef HAVE_CONST_CAST
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Use regex support
|
* Use regex support
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user