Boost C++ Libraries: Ticket #6219: Apple macros break compile of has_binary_operator https://svn.boost.org/trac10/ticket/6219 <p> Short version: the Apple defined macro for check() breaks the compile of some files in Boost 1.48. </p> <p> Long version </p> <p> I upgraded from Boost 1.44 to 1.48 and my compile broke. A little digging determined it is a conflict with the check() macro defined in <a class="missing wiki">AssertMacros</a>.h which currently makes its way into many compiles. This problem has come up before, see <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/2115"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/2115</a>. </p> <p> I am compiling on Mac OS X Lion v10.7.2 with Apple LLVM compiler 3.0. This code is enough to show the problem: </p> <p> #include &lt;<a class="missing wiki">Carbon/Carbon</a>.h&gt; #include "boost/type_traits.hpp" </p> <p> or more directly #include &lt;<a class="missing wiki">AssertMacros</a>.h&gt; #include "boost/type_traits.hpp" </p> <p> The first errors happen in this code in has_binary_operator.hpp where check is used. </p> <pre class="wiki">template &lt; typename Lhs, typename Rhs &gt; struct operator_exists { static ::boost::type_traits::yes_type check(has_operator); // this version is preferred when operator exists static ::boost::type_traits::no_type check(no_operator); // this version is used otherwise BOOST_STATIC_CONSTANT(bool, value = (sizeof(check(((make&lt;Lhs&gt;() BOOST_TT_TRAIT_OP make&lt;Rhs&gt;()),make&lt;has_operator&gt;())))==sizeof(::boost::type_traits::yes_type))); }; </pre><p> Of some interest, Apple is aware of the problems being caused by the too-ordinary macro names and this text appears in the <a class="missing wiki">AssertMacros</a>.h header: </p> <pre class="wiki">* Prior to Mac OS X 10.6 the macro names used in this file conflicted with some * user code, including libraries in boost and the proposed C++ standards efforts, * and there was no way for a client of this header to resolve this conflict. Because * of this, most of the macros have been changed so that they are prefixed with * __ and contain at least one capital letter, which should alleviate the current * and future conflicts. However, to allow current sources to continue to compile, * compatibility macros are defined at the end with the old names. A tops script * at the end of this file will convert all of the old macro names used in a directory * to the new names. Clients are recommended to migrate over to these new macros as * they update their sources because a future release of Mac OS X will remove the * old macro definitions ( without the double-underscore prefix ). Clients who * want to compile without the old macro definitions can define the macro * __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is * included. </pre><p> (So there is a work-around in client code.) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6219 Trac 1.4.3 John Gee <j.gee@…> Mon, 05 Dec 2011 21:48:56 GMT <link>https://svn.boost.org/trac10/ticket/6219#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:1</guid> <description> <p> (I regret not previewing the report, mea culpa for the cosmetic grinkles.) </p> </description> <category>Ticket</category> </item> <item> <author>John Gee <j.gee@…></author> <pubDate>Mon, 05 Dec 2011 21:49:46 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/6219#comment:2 https://svn.boost.org/trac10/ticket/6219#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">j.gee@…</span> added </li> </ul> Ticket Marshall Clow Mon, 05 Dec 2011 22:19:11 GMT <link>https://svn.boost.org/trac10/ticket/6219#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:3</guid> <description> <p> This definition <code> __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 </code> should definitely go into the darwin tool config. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 05 Dec 2011 22:25:57 GMT</pubDate> <title>component changed; owner set https://svn.boost.org/trac10/ticket/6219#comment:4 https://svn.boost.org/trac10/ticket/6219#comment:4 <ul> <li><strong>owner</strong> set to <span class="trac-author">Vladimir Prus</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Building Boost</span> </li> </ul> <p> Should probably also go into the clang-darwin toolset as well. </p> <p> Changing to "building boost", and assigning to Vladmir. If he's not the right person, I'm sure he'll chime in. </p> Ticket René Rivera Wed, 07 Dec 2011 02:53:11 GMT component changed https://svn.boost.org/trac10/ticket/6219#comment:5 https://svn.boost.org/trac10/ticket/6219#comment:5 <ul> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">Regression Testing</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6219#comment:3" title="Comment 3">marshall</a>: </p> <blockquote class="citation"> <p> This definition <code> __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 </code> should definitely go into the darwin tool config. </p> </blockquote> <p> Perhaps.. But that doesn't actually solve the problem. For users that do not use BB it would still break. As would also anyone compiling with an older OSX,or iOS, SDK. So we need to identify where the problems in the code are an file individual bugs. And as a preliminary step we should add this macro to the inspection report, if it's not already there. And because of that I'm shifting this to the testing side. </p> Ticket viboes Thu, 03 Jan 2013 18:54:55 GMT component changed https://svn.boost.org/trac10/ticket/6219#comment:6 https://svn.boost.org/trac10/ticket/6219#comment:6 <ul> <li><strong>component</strong> <span class="trac-field-old">Regression Testing</span> → <span class="trac-field-new">type_traits</span> </li> </ul> Ticket ben.craig@… Mon, 06 Jan 2014 20:45:16 GMT <link>https://svn.boost.org/trac10/ticket/6219#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:7</guid> <description> <p> Just ran into this with boost 1.55. This could be fixed without ever touching ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES. Just change the static variable names in operator_exists ( type_traits/detail/has_binary_operator.hpp ) from "check" to something else. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Mon, 06 Jan 2014 21:55:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6219#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:8</guid> <description> <p> Sadly, there is lots more than just this. </p> <ul><li>boost/container/detail/function_detector.hpp has a template member named "check" </li><li>Boost.Concept has structures named both "check" and "require" </li><li>Boost.Geometry has several uses of "check" </li></ul><p> and the file <code>&lt;AssertMacros.h&gt;</code> defines many more macros than just those two. </p> </description> <category>Ticket</category> </item> <item> <author>ben.craig@…</author> <pubDate>Mon, 06 Jan 2014 22:05:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6219#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:9</guid> <description> <p> The perfect is the enemy of the good? </p> <p> Fixing has_binary_operator.hpp fixes a lot of real use cases (lexical_cast for one) by just changing some internal identifiers. Even if you don't fix every use case, you make some use cases better, without making any use cases worse. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 15 Jan 2014 11:50:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6219#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6219#comment:10</guid> <description> <p> This took me almost two hours to sort out yesterday. Perhaps the addition of something like... </p> <pre class="wiki">#if defined(__MACH__) &amp;&amp; defined(__APPLE__) &amp;&amp; defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) &amp;&amp; __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES #warning You will need to define ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before the inclusion of Cocoa headers (perhaps in your prefix header) #end if </pre><p> ...might help lower the impedance here. Or something to that effect. While it may be non-trivial to work around this vendor annoyance, mankind does possess the technology to at least shorten the path to the workaround. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Sun, 20 Apr 2014 15:58:52 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6219#comment:11 https://svn.boost.org/trac10/ticket/6219#comment:11 <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> This is fixed in current develop (or at least type_traits is, can't comment on other libraries). </p> Ticket