Skip to content

Commit e7ffcb6

Browse files
committed
Document that the definition file needs the archive headers
`BOOST_CLASS_EXPORT_IMPLEMENT` instantiates serialization code only for the archive classes whose headers its translation unit has seen, so a definition file which includes none of them instantiates nothing, and serializing a pointer to the class throws `unregistered_class` at run time. The rule was stated for `BOOST_CLASS_EXPORT`, but both passages which send the reader to the `_KEY` and `_IMPLEMENT` pair presented that split as the answer to the include ordering problem without saying that the definition file still has to follow it. Refs #327.
1 parent 81d7615 commit e7ffcb6

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

doc/special.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,17 @@ <h3><a name="export">Exporting Class Serialization</a></h3>
444444
<code style="white-space: normal">BOOST_CLASS_EXPORT_IMPLEMENT</code>
445445
in the class definition file.
446446

447+
<p>
448+
This makes the rule easy to follow but does not remove it. The definition
449+
file has to include the archive class headers itself, before
450+
<code style="white-space: normal">BOOST_CLASS_EXPORT_IMPLEMENT</code>
451+
is invoked, just as it would for
452+
<code style="white-space: normal">BOOST_CLASS_EXPORT</code>.
453+
A definition file which includes none of them instantiates no serialization
454+
code at all, and serializing a pointer to such a class then throws
455+
<code style="white-space: normal">unregistered_class</code>
456+
when the program is run.
457+
447458
<p>
448459
This system has certain implications for placing code in static or shared
449460
libraries. Placing <code style="white-space: normal">BOOST_CLASS_EXPORT</code>

doc/traits.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,11 @@ <h3><a name="export">Export Key</a></h3>
247247
This is addressed by invoking
248248
<code style="white-space: normal">BOOST_CLASS_EXPORT_IMPLEMENT(T)</code>
249249
in the file which defines (implements) the class T.
250-
This ensures that code for the derived class T will
251-
be explicitly instantiated.
250+
That instantiates the code for the archive classes whose headers the file
251+
includes, so the file has to include them before the macro is invoked.
252+
See
253+
<a href="special.html#export">Exporting Class Serialization</a>
254+
for the details, and for what happens when it includes none of them.
252255
<li> There needs to be some sort of identifier which can
253256
be used to select the code to be invoked when the object
254257
is loaded.

0 commit comments

Comments
 (0)