1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
5 <title>Mixing sources with RTTI on and RTTI off</title>
6 <link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css">
7 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
8 <link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
9 <link rel="up" href="../boost_typeindex.html" title="Chapter 41. Boost.TypeIndex 4.1">
10 <link rel="prev" href="rtti_emulation_limitations.html" title="RTTI emulation limitations">
11 <link rel="next" href="acknowledgements.html" title="Acknowledgements">
13 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14 <table cellpadding="2" width="100%"><tr>
15 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td>
16 <td align="center"><a href="../../../index.html">Home</a></td>
17 <td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td>
18 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
19 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
20 <td align="center"><a href="../../../more/index.htm">More</a></td>
23 <div class="spirit-nav">
24 <a accesskey="p" href="rtti_emulation_limitations.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_typeindex.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>
27 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
28 <a name="boost_typeindex.mixing_sources_with_rtti_on_and_"></a><a class="link" href="mixing_sources_with_rtti_on_and_.html" title="Mixing sources with RTTI on and RTTI off">Mixing
29 sources with RTTI on and RTTI off</a>
30 </h2></div></div></div>
32 Linking a binary from source files that were compiled with different RTTI flags
33 is not a very good idea and may lead to a lot of surprises. However if there
34 is a very strong need, TypeIndex library provides a solution for mixing sources:
35 just define <code class="computeroutput"><a class="link" href="../BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY.html" title="Macro BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY">BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY</a></code>
36 macro. This would lead to usage of same type_index class (<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">typeindex</span><span class="special">::</span><span class="identifier">ctti_type_index</span></code>
37 or <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">typeindex</span><span class="special">::</span><span class="identifier">stl_type_index</span></code>) all around the project.
39 <div class="note"><table border="0" summary="Note">
41 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../doc/src/images/note.png"></td>
42 <th align="left">Note</th>
44 <tr><td align="left" valign="top"><p>
45 Do not forget to rebuild <span class="bold"><strong>all</strong></span> the projects
46 with <code class="computeroutput"><span class="identifier">BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY</span></code>
51 You must know that linking RTTI on and RTTI off binaries may succeed even without
52 defining the <code class="computeroutput"><span class="identifier">BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY</span></code>
53 macro, but that does not mean that you'll get a working binary. Such actions
54 may break the One Definition Rule. Take a look at the table below, that shows
55 how the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">type_index</span> <span class="identifier">get_integer</span><span class="special">();</span></code> function will look like with different RTTI
58 <div class="informaltable">
59 <a name="boost_typeindex.mixing_sources_with_rtti_on_and_.diffs"></a><table class="table">
79 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">typeindex</span><span class="special">::</span><span class="identifier">stl_type_index</span> <span class="identifier">get_integer</span><span class="special">();</span></code>
84 <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">typeindex</span><span class="special">::</span><span class="identifier">ctti_type_index</span> <span class="identifier">get_integer</span><span class="special">();</span></code>
91 Such differences are usually not detected by linker and lead to errors at runtime.
93 <div class="warning"><table border="0" summary="Warning">
95 <td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../doc/src/images/warning.png"></td>
96 <th align="left">Warning</th>
98 <tr><td align="left" valign="top"><p>
99 Even with <code class="computeroutput"><span class="identifier">BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY</span></code>
100 defined there is no guarantee that everything will be OK. Libraries that
101 use their own workarounds for disabled RTTI may fail to link or to work correctly.
105 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
106 <td align="left"></td>
107 <td align="right"><div class="copyright-footer">Copyright © 2012-2016 Antony Polukhin<p>
108 Distributed under the Boost Software License, Version 1.0. (See accompanying
109 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
114 <div class="spirit-nav">
115 <a accesskey="p" href="rtti_emulation_limitations.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_typeindex.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="../../../doc/src/images/next.png" alt="Next"></a>