0

在尝试使用 C++ 编译 Mesosphere 的 RENDLER 后make all,我收到以下错误:

$ make all
g++  -g -O2 -pthread -o rendler rendler.cpp -lmesos -lpthread -lprotobuf
In file included from /usr/local/include/stout/stringify.hpp:26:0,
                 from /usr/local/include/stout/bytes.hpp:26,
                 from /usr/local/include/mesos/resources.hpp:29,
                 from rendler.cpp:30:
/usr/local/include/stout/hashmap.hpp:43:32: error: expected ‘)’ before ‘<’ token
   hashmap(std::initializer_list<std::pair<Key, Value>> list)
                                ^
rendler.cpp:345:1: error: expected ‘}’ at end of input
 }
 ^
In file included from /usr/local/include/stout/stringify.hpp:26:0,
                 from /usr/local/include/stout/bytes.hpp:26,
                 from /usr/local/include/mesos/resources.hpp:29,
                 from rendler.cpp:30:
/usr/local/include/stout/hashmap.hpp:40:14: error: expected unqualified-id at end of input
   hashmap() {}
              ^
make: *** [rendler] Error 1

我在正确的包含路径中安装了所有列出的依赖项以及相关的 3rd 方库。尝试编译mesos/src/examples目录中的示例框架时,我收到相同的错误。是什么导致了这个错误?

4

1 回答 1

0

这段代码

     std::initializer_list<std::pair<Key, Value>>
  // ^^^^^^^^^^^^^^^^^^^^^

导致错误

 error: expected ‘)’ before ‘&lt;’ token

对于 pre stanadard c++11 编译器,因为std::initializer_list最早是在 c++11 中引入的。

大多数最新的编译器(如 GCC)都允许设置该-std=c++11选项,这应该可以修复您的错误。

于 2015-05-22T17:18:59.490 回答