Boost C++ Libraries: Ticket #2544: BOOST_CLASS_EXPORT uses __LINE__ in variable declaration https://svn.boost.org/trac10/ticket/2544 <p> Bug --- Using boost serialization. Declaring various derived types in separate files. Each type has a corresponding: </p> <p> BOOST_CLASS_EXPORT or BOOST_CLASS_EXPORT_GUID </p> <p> Have two or more files with the BOOST_CLASS_EXPORT/_GUID on the SAME line. </p> <p> Obtain a compile "error C2371: '`anonymous-namespace'::boost_serialization_guid_initializer_29' : redefinition; different basic types" </p> <p> Diagnosis </p> <hr /> <p> Since (at least) boost 1.36 (not boost 1.34) in 'serialization/export.hpp' in the macro definition of BOOST_CLASS_EXPORT_GUID a variable is defined as so: </p> <p> BOOST_PP_CAT(boost_serialization_guid_initializer_, <span class="underline">LINE</span>) </p> <h1 class="section" id="::boost::serialization::singleton">::boost::serialization::singleton&lt; …</h1> <p> Clearly, by using <span class="underline">LINE</span> every call to the macro *must be on a different line*, otherwise an error as above will occur. </p> <p> Proposed Solution </p> <hr /> <p> I can't say that I know the ins and outs of boost too well but if '<span class="underline">LINE</span>' is replaced by 'T' -- a variable in the macro specifying the classname -- then the generated variable name will be guaranteed to be unique (and valid?) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2544 Trac 1.4.3 Robert Ramey Sat, 29 Nov 2008 07:47:24 GMT status changed https://svn.boost.org/trac10/ticket/2544#comment:1 https://svn.boost.org/trac10/ticket/2544#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Problem is that T might might be a template instatiation like list&lt;int&gt; - so the proposed solution wouldnn't work for templates </p> Ticket anonymous Fri, 05 Dec 2008 16:58:40 GMT <link>https://svn.boost.org/trac10/ticket/2544#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2544#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2544#comment:1" title="Comment 1">ramey</a>: </p> <blockquote class="citation"> <p> Problem is that T might might be a template instatiation like list&lt;int&gt; - so the proposed solution wouldnn't work for templates </p> </blockquote> <p> I just submitted ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2569" title="#2569: Patches: export macro cannot be used on same line # in different files in same ... (closed: fixed)">#2569</a> which is unfortunately a duplicate of this ticket (my apologies for that). However, I did attach a patch to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2569" title="#2569: Patches: export macro cannot be used on same line # in different files in same ... (closed: fixed)">#2569</a> that fixed the issue in all of my use cases. It has not been run against any unit tests, so there may be unknown issues that invalidate it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Thu, 11 Dec 2008 17:12:39 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2544#comment:3 https://svn.boost.org/trac10/ticket/2544#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket