Boost C++ Libraries: Ticket #6455: Boost foreach conflicts with Q_FOREACH and moc generation. https://svn.boost.org/trac10/ticket/6455 <p> The change to fix Ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6131" title="#6131: Bugs: #define foreach BOOST_FOREACH causes weird compile error in certain ... (closed: fixed)">#6131</a> caused a latent bug to manifest in the interaction with the Qt header qglobal.h. </p> <p> The header replaces all instances of foreach with Q_FOREACH. In version 1.47 this replacement was consistent. In version 1.48 the move of is_lightweight_proxy&lt;T&gt; and is_noncopyable&lt;T&gt; to the BOOST_FOREACH namespace causes errors: </p> <p> c:\boost\alg_1_48_0_64\boost\foreach.hpp(169): error C2039: 'tag' : is not a member of 'boost::Q_FOREACH' c:\boost\alg_1_48_0_64\boost\foreach.hpp(169): error C2061: syntax error : identifier 'tag' </p> <p> A workaround is to turn off this substitution by defining QT_NO_KEYWORDS. </p> <p> This will also require replacing all keywords signals and slots with Q_SIGNALS and Q_SLOTS. </p> <p> It would be nice if these libs could co-exist. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6455 Trac 1.4.3 smr@… Sat, 11 Feb 2012 18:10:54 GMT cc set https://svn.boost.org/trac10/ticket/6455#comment:1 https://svn.boost.org/trac10/ticket/6455#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">smr@…</span> added </li> </ul> Ticket Eric Niebler Mon, 19 Mar 2012 22:07:02 GMT status changed https://svn.boost.org/trac10/ticket/6455#comment:2 https://svn.boost.org/trac10/ticket/6455#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Thanks. It seems the fix to <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6131" title="#6131: Bugs: #define foreach BOOST_FOREACH causes weird compile error in certain ... (closed: fixed)">#6131</a> is doing more harm than good. It's been reverted on trunk, and will be merged to release as soon as the tests cycle. Thanks. </p> Ticket Eric Niebler Tue, 27 Mar 2012 19:28:34 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6455#comment:3 https://svn.boost.org/trac10/ticket/6455#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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/77591" title="merge [77416] from trunk, fixes #6131, fixes #6455">[77591]</a>) merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/77416" title="reverting [75540] which seemed to make things worse">[77416]</a> from trunk, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6131" title="#6131: Bugs: #define foreach BOOST_FOREACH causes weird compile error in certain ... (closed: fixed)">#6131</a>, fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6455" title="#6455: Feature Requests: Boost foreach conflicts with Q_FOREACH and moc generation. (closed: fixed)">#6455</a> </p> Ticket bekveron@… Tue, 20 Aug 2013 17:09:50 GMT <link>https://svn.boost.org/trac10/ticket/6455#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6455#comment:4</guid> <description> <p> I'm having the same problem with boost 1.54.0 and Qt. Thought the issue has been fixed. So the libs are still incompatible? Do you recommend to use this workaround with QT_NO_KEYWORDS? </p> </description> <category>Ticket</category> </item> <item> <author>alex@…</author> <pubDate>Wed, 23 Jul 2014 09:38:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6455#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6455#comment:5</guid> <description> <p> Hi, </p> <p> I'm still having issues with &lt;boost/foreach.hpp&gt; and Qt's foreach with various recent versions of boost (checked that the issue is present in 1.50.0 and 1.55.0). I will attach a single-file test case which demonstrates the issue where the application fails to compile with the BOOST_FOREACH construct present in a Qt application. The number and order of include files appears to be key, if you cut it down to just the core application and the &lt;boost/foreach.hpp&gt; include then the error is gone, so there's some interplay going on here. I'll also attach the errors I get when compiling on this platform (OSX 10.9 against boost 1.55.0, clang x86_64). </p> </description> <category>Ticket</category> </item> <item> <author>alex@…</author> <pubDate>Wed, 23 Jul 2014 09:41:32 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6455 https://svn.boost.org/trac10/ticket/6455 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_foreach_qt_error_example.cpp</span> </li> </ul> <p> A test case for boost foreach's interplay with qt's foreach keyword </p> Ticket alex@… Wed, 23 Jul 2014 09:42:14 GMT attachment set https://svn.boost.org/trac10/ticket/6455 https://svn.boost.org/trac10/ticket/6455 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_foreach_error_output.txt</span> </li> </ul> <p> Error output for the attached testcase for OSX 10.9 against boost 1.55.0 </p> Ticket alex@… Wed, 23 Jul 2014 09:45:48 GMT <link>https://svn.boost.org/trac10/ticket/6455#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6455#comment:6</guid> <description> <p> Oh my word that's so embarrassing, I had the wrong tab open in the build preferences, I am getting an error as the output shows, but my test-case still isn't working to show it. I'll work on getting it right and come back to you. If an admin wants to clean this up feel free. </p> </description> <category>Ticket</category> </item> </channel> </rss>