Boost C++ Libraries: Ticket #11876: Boost.Graph conflicts with Qt's foreach macro https://svn.boost.org/trac10/ticket/11876 <p> This is a similar problem as <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/6455"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/6455</a>, where the Qt <code>foreach</code> macro conflicts with the <code>boost::foreach::tag</code> in file <code>/usr/include/boost/foreach.hpp</code>. </p> <p> This is a simple Qt example that reproduces the error (also supplied as an attachment): </p> <pre class="wiki">#include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;QCoreApplication&gt; #include &lt;fstream&gt; #include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;boost/graph/graphviz.hpp&gt; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); std::ofstream f("filename.dot"); boost::write_graphviz( f, boost::adjacency_list&lt;&gt;() ); return a.exec(); } </pre><p> For the following Qt Creator project file: </p> <pre class="wiki">QT += core QT -= gui CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp </pre><p> The error given is: </p> <pre class="wiki">In file included from /usr/include/boost/graph/graphviz.hpp:35:0, from ../CppBoostGraphAndQtConflictQtConsole/main.cpp:5: /usr/include/boost/foreach.hpp:169:42: error: 'boost::Q_FOREACH::tag' has not been declared boost_foreach_is_lightweight_proxy(T *&amp;, BOOST_FOREACH_TAG_DEFAULT) { return 0; } </pre><p> The error does not occur if 'boost/graph/adjacency_list.hpp' is #included either before <code>QCoreApplication</code> or after. This is a workaround. </p> <p> I cannot see if this error is still present in later versions of Boost. If it is still present, I hope I have contributed in letting Boost.Graph and Qt work together seamlessly. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11876 Trac 1.4.3 richel@… Mon, 28 Dec 2015 14:57:24 GMT attachment set https://svn.boost.org/trac10/ticket/11876 https://svn.boost.org/trac10/ticket/11876 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">CppBoostGraphAndQtConflictQtConsole.zip</span> </li> </ul> <p> Qt Creator project that reproduces the compile error </p> Ticket viboes Sun, 03 Jan 2016 16:46:19 GMT component changed; owner set https://svn.boost.org/trac10/ticket/11876#comment:1 https://svn.boost.org/trac10/ticket/11876#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">graph</span> </li> </ul> Ticket