Boost C++ Libraries: Ticket #12179: Including boost/optional/optional_fwd.hpp without first including boost/config.hpp doesn't compile. https://svn.boost.org/trac10/ticket/12179 <p> This code does not compile; </p> <p> #include &lt;boost/optional/optional_fwd.hpp&gt; </p> <p> int main() { </p> <blockquote> <p> return 0; </p> </blockquote> <p> } </p> <p> It seems this is because optional_fwd.hpp tries to only depend on boost/config/suffix.hpp, but this file itself depends on other config macros that need to be included first. </p> <p> I have been able to workaround this issue by including boost/config.hpp before optional_fwd.hpp </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12179 Trac 1.4.3 post@… Sat, 14 May 2016 08:36:15 GMT <link>https://svn.boost.org/trac10/ticket/12179#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12179#comment:1</guid> <description> <p> Here's a slightly different problem, but with the same solution: </p> <p> If optional/optional_fwd.hpp is included before any boost header that includes config.hpp (for example optional.hpp), there are multiple problems. Example: </p> <pre class="wiki">#include "boost/optional/optional_fwd.hpp" #include "boost/optional.hpp" int main() { return 0; } </pre><p> The first problem is a build failure because of inconsistent defines: </p> <ol><li>optional/optional_fwd.hpp includes config/suffix.hpp </li><li>config/suffix.hpp uses an include guard to prevent multiple inclusions of itself </li><li>config/suffix.hpp doesn't define int128_type and uint128_type because BOOST_HAS_INT128 is not defined </li><li>another boost header includes config.hpp </li><li>config.hpp includes config/compiler/gcc.hpp </li><li>config/compiler/gcc.hpp defines BOOST_HAS_INT128 </li><li>config.hpp includes config/suffix.hpp, but the include guard prevents reevaluation of the file </li></ol><p> Now, we have BOOST_HAS_INT128 defined, but boost::int128_type and boost::uint128_type are not. If we now try to compile something that includes type_traits/is_integral.hpp (which optional/optional.hpp indirectly does), we get to this code, which doesn't compile due to unknown types: </p> <pre class="wiki">#ifdef BOOST_HAS_INT128 template&lt;&gt; struct is_integral&lt;boost::int128_type&gt; : public true_type{}; template&lt;&gt; struct is_integral&lt;boost::uint128_type&gt; : public true_type{}; #endif </pre><p> The second class of problems are redefinition warnings. Here's an example (there are multiple defines that get redefined): </p> <ol><li>optional/optional_fwd.hpp includes config/suffix.hpp </li><li>config/suffix.hpp first sets BOOST_LIKELY to a no-op default </li><li>another boost header includes config.hpp </li><li>config.hpp includes config/compiler/gcc.hpp </li><li>config/compiler/gcc.hpp redefines BOOST_LIKELY to work as intended -&gt; redefinition warning </li></ol><p> As a conclusion, optional/optional_fwd.hpp should include config.hpp instead of config/suffix.hpp Currently, optional/optional_fwd.hpp is the only file in boost that includes config/suffix.hpp directly (not through config.hpp), so it's probably not meant to be used this way. </p> <p> (context: I'm using gcc 5.3.1 on Fedora 23) </p> </description> <category>Ticket</category> </item> <item> <author>post@…</author> <pubDate>Sat, 14 May 2016 08:42:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12179#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12179#comment:2</guid> <description> <p> I posted a pull request with the (trivial) fix for this problem on Github: <a class="ext-link" href="https://github.com/boostorg/optional/pull/19"><span class="icon">​</span>https://github.com/boostorg/optional/pull/19</a> </p> </description> <category>Ticket</category> </item> <item> <author>Tony Lewis <tonyelewis@…></author> <pubDate>Wed, 10 Aug 2016 19:55:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12179#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12179#comment:3</guid> <description> <p> I think this is related to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12142" title="#12142: Bugs: Including optional/optional_fwd.hpp then type_traits.hpp (closed: fixed)">ticket:12142</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>akrzemi1</dc:creator> <pubDate>Mon, 19 Sep 2016 07:42:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12179#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12179#comment:4</guid> <description> <p> A related ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12142" title="#12142: Bugs: Including optional/optional_fwd.hpp then type_traits.hpp (closed: fixed)">#12142</a> will be fixed in 1.62.0 release. Hopefully this one will be fixed as well. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>akrzemi1</dc:creator> <pubDate>Mon, 19 Sep 2016 07:43:32 GMT</pubDate> <title>status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/12179#comment:5 https://svn.boost.org/trac10/ticket/12179#comment:5 <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> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.62.0</span> </li> </ul> Ticket