diff --git a/boost/type_index/type_index_minimal.hpp b/boost/type_index/type_index_minimal.hpp index 6148ff4..42ed2a2 100644 --- a/boost/type_index/type_index_minimal.hpp +++ b/boost/type_index/type_index_minimal.hpp @@ -22,7 +22,7 @@ #include -#ifndef BOOST_NO_RTTI +#if !defined(BOOST_NO_RTTI) && !defined(BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY) # include #else # include diff --git a/libs/type_index/test/Jamfile.v2 b/libs/type_index/test/Jamfile.v2 index 0d30998..d1a2b8f 100644 --- a/libs/type_index/test/Jamfile.v2 +++ b/libs/type_index/test/Jamfile.v2 @@ -7,11 +7,29 @@ import testing ; import feature ; + # Variable that contains all the stuff required for linking against -lboost_unit_test tlib = /boost/test//boost_unit_test_framework/static ; -lib test_lib_rtti : test_lib.cpp : shared ; -lib test_lib_nortti : test_lib.cpp : shared off ; +# Variable that contains all the stuff required for linking together on and off +compat = BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY ; + +# Making own `nortti` that is link compatible +nortti = gcc:-fno-rtti clang:-fno-rtti msvc:/GR- ; + + +# Making libraries that CANNOT work between rtti-on/rtti-off modules +obj test_lib_nortti-obj : test_lib.cpp : shared $(nortti) ; +obj test_lib_rtti-obj : test_lib.cpp : shared ; +lib test_lib_rtti : test_lib_rtti-obj : shared ; +lib test_lib_nortti : test_lib_nortti-obj : shared $(nortti) ; + +# Making libraries that can work between rtti-on/rtti-off modules +obj test_lib_nortti_compat-obj : test_lib.cpp : shared $(nortti) $(compat) ; +obj test_lib_rtti_compat-obj : test_lib.cpp : shared $(nortti) $(compat) ; +lib test_lib_nortti_compat : test_lib_nortti_compat-obj : shared $(nortti) $(compat) ; +lib test_lib_rtti_compat : test_lib_rtti_compat-obj : shared $(nortti) $(compat) ; + test-suite type_index : @@ -22,18 +40,13 @@ test-suite type_index [ run testing_minimal.cpp $(tlib) ] [ run testing_minimal_no_rtti.cpp $(tlib) : : : off ] [ run testing_crossmodule.cpp test_lib_rtti $(tlib) ] - [ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : off : testing_crossmodule_no_rtti ] - - # Bjam has specific rule for not mixing on and off binaries, so we can not - # just provide `test_lib_nortti` library for `on` build. But here are some workarounds: - [ link-fail testing_crossmodule.cpp $(tlib) - : $(test_lib_nortti.location)/test_lib_nortti - : link_fail_rtti_nortti - ] - [ link-fail testing_crossmodule.cpp $(tlib) - : off $(test_lib_rtti.location)/test_lib_rtti - : link_fail_nortti_rtti - ] + [ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : $(nortti) : testing_crossmodule_no_rtti ] + + # Mixing RTTI on and off + [ link-fail testing_crossmodule.cpp $(tlib) test_lib_rtti : $(nortti) : link_fail_nortti_rtti ] + [ link-fail testing_crossmodule.cpp $(tlib) test_lib_nortti : : link_fail_rtti_nortti ] + [ run testing_crossmodule.cpp $(tlib) test_lib_rtti_compat : : : $(nortti) $(compat) : testing_crossmodule_nortti_rtti_compat ] + [ run testing_crossmodule.cpp $(tlib) test_lib_nortti_compat : : : $(compat) : testing_crossmodule_rtti_nortti_compat ] # Examples that must work even with RTTI disabled [ run ../examples/registry.cpp : : : off : registry_no_rtti ] diff --git a/libs/type_index/test/test_lib.cpp b/libs/type_index/test/test_lib.cpp index d012dac..85670bf 100644 --- a/libs/type_index/test/test_lib.cpp +++ b/libs/type_index/test/test_lib.cpp @@ -23,5 +23,9 @@ boost::type_index get_const_user_defined_class() { return boost::type_id_with_cvr(); } + +// Just do nothing +void accept_typeindex(const boost::type_index&) {} + } diff --git a/libs/type_index/test/test_lib.hpp b/libs/type_index/test/test_lib.hpp index 0bafed4..40528e8 100644 --- a/libs/type_index/test/test_lib.hpp +++ b/libs/type_index/test/test_lib.hpp @@ -31,6 +31,9 @@ TEST_LIB_DECL boost::type_index get_user_defined_class(); TEST_LIB_DECL boost::type_index get_const_integer(); TEST_LIB_DECL boost::type_index get_const_user_defined_class(); +// This is required for checking RTTI on/off linkage +TEST_LIB_DECL void accept_typeindex(const boost::type_index&); + } #endif // BOOST_TYPE_INDEX_TESTS_LIB1_HPP diff --git a/libs/type_index/test/testing_crossmodule.cpp b/libs/type_index/test/testing_crossmodule.cpp index 16d863c..d95c61b 100644 --- a/libs/type_index/test/testing_crossmodule.cpp +++ b/libs/type_index/test/testing_crossmodule.cpp @@ -39,5 +39,7 @@ BOOST_AUTO_TEST_CASE(comparing_types_between_modules) BOOST_CHECK_NE(t_const_userdef, test_lib::get_integer()); 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); }