diff --git a/boost/type_index/type_index_minimal.hpp b/boost/type_index/type_index_minimal.hpp index 42ed2a2..a7283ce 100644 --- a/boost/type_index/type_index_minimal.hpp +++ b/boost/type_index/type_index_minimal.hpp @@ -19,6 +19,9 @@ /// /// It includes only the minamally required headers and does the `typedef template_index type_index;` /// when RTTI is disabled. +/// +/// Define the BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY macro if you are mixing objects +/// compiled with different RTTI flags. #include diff --git a/libs/type_index/doc/type_index.qbk b/libs/type_index/doc/type_index.qbk index fe772cf..91f8b1d 100644 --- a/libs/type_index/doc/type_index.qbk +++ b/libs/type_index/doc/type_index.qbk @@ -119,3 +119,21 @@ Consider the following example: With `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` set to `0`, `boost::detail::ctti::n()` returns "const char *__cdecl boost::detail::ctti::n(void)". Then you shall set `BOOST_TYPE_INDEX_CTTI_BEGIN_SKIP` to `sizeof("const char *__cdecl boost::detail::ctti<") - 1` and `BOOST_TYPE_INDEX_CTTI_END_SKIP` to `sizeof(">::n(void)") - 1` [endsect] + +[section Mixing sources with RTTI on and RTTI off] + +Linking a binary from source files that were compiled with different RTTI flags is not a very good idea and may lead to a lot of surprises. However if there is a very strong need TypeIndex library provides a solution for mixing sources: just define `BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY` macro. This would lead to usage of `boost::template_index` instead of `boost::type_index` class. + +[note Do not forget to rebuild *all* the projects with `BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY` macro defined ] + +You must know that linking RTTI on and RTTI off binaries may succeed even without defining the `BOOST_TYPE_INDEX_FORCE_NORTTI_COMPATIBILITY` macro, but that does not mean that you'll get a working binary. Such actions may break the One Definition Rule. Take a look at the table below, that shows how the `boost::type_index get_integer();` function will look like with different RTTI flags: + +[table:diffs +[[RTTI on] [RTTI off]] +[[`boost::type_index get_integer();`] [`boost::template_index get_integer();`]] +] + +Such differences are usually not detected by linker and lead to errors at runtime. + +[endsect] +