Subject: [Boost-bugs] [Boost C++ Libraries] #11876: Boost.Graph conflicts with Qt's foreach macro
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-12-28 14:56:52
#11876: Boost.Graph conflicts with Qt's foreach macro
----------------------+------------------------------
Reporter: richel@⦠| Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
Severity: Problem | Keywords: Graph BGL Qt
----------------------+------------------------------
This is a similar problem as https://svn.boost.org/trac/boost/ticket/6455,
where the Qt `foreach` macro conflicts with the `boost::foreach::tag` in
file `/usr/include/boost/foreach.hpp`.
This is a simple Qt example that reproduces the error (also supplied as an
attachment):
{{{
#include <boost/graph/adjacency_list.hpp>
#include <QCoreApplication>
#include <fstream>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graphviz.hpp>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
std::ofstream f("filename.dot");
boost::write_graphviz(
f,
boost::adjacency_list<>()
);
return a.exec();
}
}}}
For the following Qt Creator project file:
{{{
QT += core
QT -= gui
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
}}}
The error given is:
{{{
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 *&, BOOST_FOREACH_TAG_DEFAULT) {
return 0; }
}}}
The error does not occur if 'boost/graph/adjacency_list.hpp' is #included
either before `QCoreApplication` or after. This is a workaround.
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.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/11876> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC