...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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 |
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 |
---|---|
|
|
Such differences are usually not detected by linker and lead to errors at runtime.
Warning | |
---|---|
Even with |