【问题标题】:boost/unordered_set: compile error with mingw ()boost/unordered_set: 使用 mingw () 编译错误
【发布时间】:2011-06-15 14:56:23
【问题描述】:

我有一段代码使用了 boost 的 unordered_set

#include <boost/unordered_set.hpp>
boost::unordered_set<string> mySet(100);

它可以在 unix 下与 gcc 一起编译并正常工作。当我尝试使用 mingw32 (gmake 3.8.1) 进行交叉编译时,我收到以下消息:

In file included 
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash/detail/hash_float.hpp:17,
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash/hash.hpp:15,
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/functional/hash.hpp:6,
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/unordered/unordered_set.hpp:17,
from /usr/i686-pc-mingw32/sys-root/mingw/include/boost/unordered_set.hpp:16,
from /mnt/VirtualBoxShare/percolator/src/ProteinProbEstimatorHelper.h:33,
from /mnt/VirtualBoxShare/percolator/src/ProteinProbEstimator.cpp:28:

/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: expected unqualified-id before 'unsigned'
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: expected ';' before 'unsigned'
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:105: error: declaration does not declare anything
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: expected unqualified-id before 'unsigned'
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: expected ';' before 'unsigned'
/usr/i686-pc-mingw32/sys-root/mingw/include/boost/cstdint.hpp:114: error: declaration does not declare anything

对我来说,这似乎是一个与模板相关的问题;有什么建议吗?

谢谢, 马蒂亚


[编辑]

其他增强功能可用,例如词法转换

#include <boost/lexical_cast.hpp>

【问题讨论】:

  • 什么版本的 MinGW 和 gcc?也许您可以使用 C++0x unordered_set 代替 boost 中的这个?
  • 什么版本的Boost?你有#include &lt;string&gt;吗?还有using std::string; 还是using namespace std;
  • @Zuljin 抱歉,mingw32-boost-1.41.0 和 mingw32-gcc-c++-4.4.2。包含字符串标题,我正在使用 std::string.

标签: boost mingw unordered-set


【解决方案1】:

似乎某些 typedef 破坏了 boost cstdint 标头,看起来像

103   using ::int8_t;
104   using ::int_least8_t;
105   using ::int_fast8_t;
106   using ::uint8_t;
107   using ::uint_least8_t;
108   using ::uint_fast8_t;

在我的系统上。因此,某些英雄可能定义了“#define uint8_t”而不是“typedef ... uint8_t”,因此这段代码会中断。

您可以尝试修改您的 boost/config/platform/win32.hpp,如果有帮助,请将错误报告给 mingw 开发人员。

【讨论】:

  • 你说得对。我发现在我的项目中有一个“英雄”做了同样的事情:#define uint8_t unsigned char
猜你喜欢
  • 2016-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多