Imported Upstream version 1.64.0
[platform/upstream/boost.git] / doc / html / boost_typeindex / mixing_sources_with_rtti_on_and_.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
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&#160;41.&#160;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">
12 </head>
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>
21 </tr></table>
22 <hr>
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>
25 </div>
26 <div class="section">
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>
31 <p>
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.
38     </p>
39 <div class="note"><table border="0" summary="Note">
40 <tr>
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>
43 </tr>
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>
47         macro defined
48       </p></td></tr>
49 </table></div>
50 <p>
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
56       flags:
57     </p>
58 <div class="informaltable">
59 <a name="boost_typeindex.mixing_sources_with_rtti_on_and_.diffs"></a><table class="table">
60 <colgroup>
61 <col>
62 <col>
63 </colgroup>
64 <thead><tr>
65 <th>
66               <p>
67                 RTTI on
68               </p>
69             </th>
70 <th>
71               <p>
72                 RTTI off
73               </p>
74             </th>
75 </tr></thead>
76 <tbody><tr>
77 <td>
78               <p>
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>
80               </p>
81             </td>
82 <td>
83               <p>
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>
85               </p>
86             </td>
87 </tr></tbody>
88 </table>
89 </div>
90 <p>
91       Such differences are usually not detected by linker and lead to errors at runtime.
92     </p>
93 <div class="warning"><table border="0" summary="Warning">
94 <tr>
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>
97 </tr>
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.
102       </p></td></tr>
103 </table></div>
104 </div>
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 &#169; 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>)
110       </p>
111 </div></td>
112 </tr></table>
113 <hr>
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>
116 </div>
117 </body>
118 </html>