| Home | Libraries | People | FAQ | More

## 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_NO_RTTI_COMPATIBILITY` macro. This would lead to usage of same type_index class (`boost::typeindex::ctti_type_index` or `boost::typeindex::stl_type_index`) all around the project.

| Note
Do not forget to rebuild all the projects with `BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY` macro defined

You must know that linking RTTI on and RTTI off binaries may succeed even without defining the `BOOST_TYPE_INDEX_FORCE_NO_RTTI_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:

RTTI on | RTTI off
--- | ---
`boost::typeindex::stl_type_index get_integer();` | `boost::typeindex::ctti_type_index get_integer();`

Such differences are usually not detected by linker and lead to errors at runtime.

| Warning
Even with `BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY` defined there is no guarantee that everything will be OK. Libraries that use their own workarounds for disabled RTTI may fail to link or to work correctly.