error: ' boost::Q_FOREACH '没有被声明

error: ‘boost::Q_FOREACH’ has not been declared

本文关键字:声明 boost error FOREACH      更新时间:2023-10-16

我使用的是boost 1.54和Qt 5.2.1版本。

当我尝试构建包

时,我得到以下错误
/usr/include/boost/multi_index/sequenced_index.hpp:927:10: error: 'boost::Q_FOREACH’ has not been declared
 boost::foreach::tag
        ^
/usr/include/boost/multi_index/ordered_index.hpp:1399:10: error: ‘boost::Q_FOREACH’ has not been declared
 boost::foreach::tag)
    ^

检查sequenced_index.hpp, ordered_index.hpp的标题,它们都包含foreach_fwd.hppforeach.hpp。我尝试在项目文件(.pro)中包括CONFIG += no_keywords。但我还是会得到这个错误。我不确定是什么原因。

需要说明的是,这个问题在即将发布的Boost 1.60版本中已经被规避了,这样你就可以让Qt定义宏foreach