Boost C++ Libraries: Ticket #2760: A problem with serialization libraries when compilin on vc9 with /Za https://svn.boost.org/trac10/ticket/2760 <p> I have a compilation problem when serializing to a text_oarchive. The problem doesn't happen when serializing to a binary_oarchive. here's a sample code: </p> <p> #include &lt;boost/test/unit_test.hpp&gt; </p> <p> #include &lt;boost/serialization/serialization.hpp&gt; #include &lt;boost/archive/text_oarchive.hpp&gt; #include &lt;boost/archive/binary_oarchive.hpp&gt; #include &lt;boost/serialization/tracking.hpp&gt; </p> <p> struct <a class="missing wiki">SerializableStruct</a> { </p> <blockquote> <p> int m_data; </p> </blockquote> <p> }; </p> <p> namespace boost { </p> <blockquote> <p> namespace serialization { </p> <blockquote> <p> template&lt;class Archive&gt; void serialize(Archive &amp; ar, <a class="missing wiki">SerializableStruct</a> &amp; s, unsigned int ) { </p> <blockquote> <p> ar &amp; s.m_data; </p> </blockquote> <p> } </p> </blockquote> <p> } </p> </blockquote> <p> } </p> <p> BOOST_CLASS_TRACKING(<a class="missing wiki">SerializableStruct</a>,boost::serialization::track_never); </p> <p> BOOST_AUTO_TEST_SUITE(<a class="missing wiki">TestGeneralSerialize</a>) </p> <p> BOOST_AUTO_TEST_CASE(<a class="missing wiki">TestTextArchive</a>) { </p> <blockquote> <p> boost::archive::text_oarchive out(std::cout); <a class="missing wiki">SerializableStruct</a> s; s.m_data = 10; out &lt;&lt; s; </p> </blockquote> <p> } </p> <p> BOOST_AUTO_TEST_CASE(<a class="missing wiki">TestBinaryArchive</a>) { </p> <blockquote> <p> std::stringstream str; boost::archive::binary_oarchive out(str); <a class="missing wiki">SerializableStruct</a> s; s.m_data = 10; out &lt;&lt; s; </p> </blockquote> <p> } </p> <p> BOOST_AUTO_TEST_SUITE_END(); </p> <p> The code compiles fine under boost 1.35, or when using /Za (Enable language extensions), but fails in boost\archive\detail\oserializer.hpp line 538, BOOST_STATIC_WARNING (...) This code should require no language extension during compilation. </p> <p> Greg </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2760 Trac 1.4.3 Robert Ramey Thu, 19 Feb 2009 16:49:56 GMT <link>https://svn.boost.org/trac10/ticket/2760#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:1</guid> <description> <p> This is likely an issue with the implementation of BOOST_STATIC_WARNING for this compiler. Perhaps you want to run test_static_warning and post the results. Assuming that this is correct, perhaps you might want to suggest a tweak to BOOST_STATIC_WARNING which would address the issue. </p> <p> Robert Ramey </p> </description> <category>Ticket</category> </item> <item> <author>Greg Ravikovich <grisharav@…></author> <pubDate>Thu, 19 Feb 2009 20:27:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2760#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:2</guid> <description> <p> I have played around with this and found out the following: The code: #include &lt;boost/static_warning.hpp&gt; </p> <p> void <a class="missing wiki">ShouldCompile</a>() { </p> <blockquote> <p> BOOST_STATIC_WARNING(true); </p> </blockquote> <p> } Doesn't compile with /Za </p> <p> If I change the line # 163 from just a bracket to "} a" The code compiles fine. This is not a solution since there are lots of different implementations depending on the compiler, the writer of BOOST_STATIC_WARNING should check this. </p> <p> Greg </p> </description> <category>Ticket</category> </item> <item> <author>Greg Ravikovich <grisharav@…></author> <pubDate>Thu, 19 Feb 2009 20:32:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2760#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:3</guid> <description> <p> Line 163 in static_warning.hpp, is the line... </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 10 Mar 2009 05:11:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2760#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:4</guid> <description> <p> Can't figure out what you're suggesting here. Line 163 in static_warning.hpp is a comment. </p> </description> <category>Ticket</category> </item> <item> <author>Greg Ravikovich <grisharav@…></author> <pubDate>Tue, 10 Mar 2009 20:25:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2760#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2760#comment:4" title="Comment 4">ramey</a>: </p> <blockquote class="citation"> <p> Can't figure out what you're suggesting here. Line 163 in static_warning.hpp is a comment. </p> </blockquote> <p> No, line 163 in static_warning.hpp is the closing bracket for an unnamed struct containing the actual implementation. Giving it some name ('a' for example) solves the compilation error. I don't really have a suggestion there, I think the best way would be to use some other implementation of static_warning (maybe another one from the same file?) Greg </p> </description> <category>Ticket</category> </item> <item> <author>Greg Ravikovich <grisharav@…></author> <pubDate>Tue, 10 Mar 2009 20:53:28 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2760#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2760#comment:6</guid> <description> <p> Another thought might be changing to BOOST_STATIC_ASSERT </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Sun, 22 Mar 2009 21:22:10 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2760#comment:7 https://svn.boost.org/trac10/ticket/2760#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> OK - think I fixed this in the next version </p> Ticket