diff --git a/doc/type_index.qbk b/doc/type_index.qbk index 586ba5f..4382b90 100644 --- a/doc/type_index.qbk +++ b/doc/type_index.qbk @@ -463,5 +463,6 @@ In order of helping and advising: * Peter Dimov for writing source codes in late 2007, that gave me an idea of how to emulate RTTI. * Agustín Bergé K-ballo for helping with docs and fixing a lot of typos. * Niall Douglas for generating a lot of great ideas, reviewing the sources and being the review manager for the library. +* All the library reviewers, especially Andrey Semashev, for making good notes and proposing improvements to the library. [endsect] diff --git a/include/boost/type_index.hpp b/include/boost/type_index.hpp index 7cbf4dc..fe10b4e 100644 --- a/include/boost/type_index.hpp +++ b/include/boost/type_index.hpp @@ -22,14 +22,27 @@ #if defined(BOOST_TYPE_INDEX_USER_TYPEINDEX) # include BOOST_TYPE_INDEX_USER_TYPEINDEX +# ifdef BOOST_HAS_PRAGMA_DETECT_MISMATCH +# pragma detect_mismatch( "boost__type_index__abi", "user defined type_index class is used: " BOOST_STRINGIZE(BOOST_TYPE_INDEX_USER_TYPEINDEX)) +# endif #elif (!defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)) || defined(BOOST_MSVC) # include # ifdef BOOST_NO_RTTI # include +# ifdef BOOST_HAS_PRAGMA_DETECT_MISMATCH +# pragma detect_mismatch( "boost__type_index__abi", "RTTI is off - typeid() is used only for templates") +# endif +# else +# ifdef BOOST_HAS_PRAGMA_DETECT_MISMATCH +# pragma detect_mismatch( "boost__type_index__abi", "RTTI is used") +# endif # endif #else # include # include +# ifdef BOOST_HAS_PRAGMA_DETECT_MISMATCH +# pragma detect_mismatch( "boost__type_index__abi", "RTTI is off - using CTTI") +# endif #endif #ifndef BOOST_TYPE_INDEX_REGISTER_CLASS diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index da03d66..2e69e48 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -51,8 +51,8 @@ test-suite type_index # Mixing RTTI on and off [ link-fail testing_crossmodule.cpp test_lib_rtti : $(nortti) : link_fail_nortti_rtti ] - # MSVC sometimes overrides the /GR-, that's why the following tests is disabled - #[ link-fail testing_crossmodule.cpp test_lib_nortti : : link_fail_rtti_nortti ] + # MSVC sometimes overrides the /GR-, without `detect_missmatch` this test may link + [ link-fail testing_crossmodule.cpp test_lib_nortti : : link_fail_rtti_nortti ] [ run testing_crossmodule.cpp test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ] [ run testing_crossmodule.cpp test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ] ; diff --git a/test/test_lib.cpp b/test/test_lib.cpp index f0680ce..7935ca5 100644 --- a/test/test_lib.cpp +++ b/test/test_lib.cpp @@ -31,9 +31,10 @@ boost::typeindex::type_index get_const_user_defined_class() { return boost::typeindex::type_id_with_cvr(); } - +#ifndef BOOST_HAS_PRAGMA_DETECT_MISMATCH // Just do nothing void accept_typeindex(const boost::typeindex::type_index&) {} +#endif } diff --git a/test/test_lib.hpp b/test/test_lib.hpp index 8521312..82a468a 100644 --- a/test/test_lib.hpp +++ b/test/test_lib.hpp @@ -31,8 +31,10 @@ TEST_LIB_DECL boost::typeindex::type_index get_user_defined_class(); TEST_LIB_DECL boost::typeindex::type_index get_const_integer(); TEST_LIB_DECL boost::typeindex::type_index get_const_user_defined_class(); +#ifndef BOOST_HAS_PRAGMA_DETECT_MISMATCH // This is required for checking RTTI on/off linkage TEST_LIB_DECL void accept_typeindex(const boost::typeindex::type_index&); +#endif } diff --git a/test/testing_crossmodule.cpp b/test/testing_crossmodule.cpp index 859d678..7b8de60 100644 --- a/test/testing_crossmodule.cpp +++ b/test/testing_crossmodule.cpp @@ -44,7 +44,9 @@ void comparing_types_between_modules() BOOST_CHECK_NE(t_int, test_lib::get_user_defined_class()); BOOST_CHECK_NE(t_const_int, test_lib::get_const_user_defined_class()); - test_lib::accept_typeindex(t_int); + #ifndef BOOST_HAS_PRAGMA_DETECT_MISMATCH + test_lib::accept_typeindex(t_int); + #endif }