Boost C++ Libraries: Ticket #1130: GCC -wundef warnings https://svn.boost.org/trac10/ticket/1130 <p> Compiling code that includes Boost headers with <code>gcc -wundef</code> produces a lot of warnings about undefined preprocessor symbols, mainly in <code>BOOST_WORKAROUND(XXX, ...)</code> where <code>XXX</code> is not defined. </p> <p> Example: </p> <p> boost/filesystem/fstream.hpp line 103: </p> <pre class="wiki"># if !BOOST_WORKAROUND( BOOST_MSVC, &lt;= 1200 ) // VC++ 6.0 can't handle this </pre><p> should probably be </p> <pre class="wiki"># if defined( BOOST_MSVC ) &amp;&amp; !BOOST_WORKAROUND( BOOST_MSVC, &lt;= 1200 ) </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1130 Trac 1.4.3 andyc@… Tue, 21 Aug 2007 09:43:18 GMT <link>https://svn.boost.org/trac10/ticket/1130#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/1130#comment:1</guid> <description> <p> I notice that this problem has been discussed previously on &lt;<a class="ext-link" href="http://lists.boost.org/Archives/boost/2005/10/95850.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2005/10/95850.php</a>&gt; and there's a proposal to do with <a class="missing wiki">BoostConfig</a> referenced there: &lt;<a class="ext-link" href="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostConfig"><span class="icon">​</span>http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?BoostConfig</a>&gt;. </p> <p> I also notice that that's proposing using constructs such as: </p> <blockquote> <p> <em> Comeau C++ #ifndef BOOST_CXX_COMO #define BOOST_CXX_COMO 0 #endif </em></p> </blockquote> <p> I wonder if you could use this instead: </p> <blockquote> <p> # define BOOST_WORKAROUND(symbol, test) \ </p> <blockquote> <p> ((BOOST_COMPILER_DEFINED_ ## symbol) &amp;&amp; \ </p> <blockquote> <p> (symbol != 0) &amp;&amp; (1 % (( (symbol test) ) + 1))) </p> </blockquote> </blockquote> </blockquote> <p> and you could then define </p> <blockquote> <p> #define BOOST_COMPILER_DEFINED_BOOST_MSVC defined(BOOST_MSVC) </p> </blockquote> <p> for each macro used in a BOOST_WORKAROUND expansion rather than all those #ifndefs. Just a thought. (I also did wonder whether there was some preprocessor magic to save having to define all those by hand but I couldn't come up with any). </p> <p> Until this problem is resolved in an official boost release, that's what we're intending to do so that we can compile with -Wundef. </p> <p> -- Andy, <a class="missing wiki">BlueArc</a> Engineering </p> </description> <category>Ticket</category> </item> <item> <dc:creator>René Rivera</dc:creator> <pubDate>Tue, 21 Aug 2007 15:18:27 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/1130#comment:2 https://svn.boost.org/trac10/ticket/1130#comment:2 <ul> <li><strong>owner</strong> set to <span class="trac-author">John Maddock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">config</span> </li> </ul> Ticket John Maddock Mon, 10 Sep 2007 09:40:28 GMT status changed https://svn.boost.org/trac10/ticket/1130#comment:3 https://svn.boost.org/trac10/ticket/1130#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> I'm working on this now, hopefully we'll work something out! </p> Ticket John Maddock Sat, 22 Sep 2007 09:27:03 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/1130#comment:4 https://svn.boost.org/trac10/ticket/1130#comment:4 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.35.0</span> </li> </ul> <p> This is hopefully now fixed with this changeset: <a class="ext-link" href="http://svn.boost.org/trac/boost/changeset/39473/trunk/boost/detail/workaround.hpp"><span class="icon">​</span>http://svn.boost.org/trac/boost/changeset/39473/trunk/boost/detail/workaround.hpp</a> </p> <p> Note that the logic we've used is the reverse of yours: the danger with your suggested fix is that if you use BOOST_WORKAROUND with a macro about which it knows nothing, then it will always evaluate to false :-( </p> <p> Regards, John Maddock. </p> Ticket