Spirit X3:无法在Ubuntu 16.04上编译任何示例

时间:2017-06-04 05:37:28

标签: c++ boost boost-spirit-x3

无法编译任何example 在Ubuntu 16.04上

$ g++ -std=c++14  main.cpp
In file included from /usr/include/boost/spirit/home/x3/nonterminal.hpp:14:0,
                 from /usr/include/boost/spirit/home/x3.hpp:20,
                 from main.cpp:23:
main.cpp:226:9: error: ‘client::calculator_grammar::parse_rule’ declared as an ‘inline’ variable
         BOOST_SPIRIT_DEFINE(
         ^
main.cpp:226:9: error: expected ‘)’ before ‘rule_’
         BOOST_SPIRIT_DEFINE(
         ^
main.cpp:226:9: error: expected primary-expression before ‘&’ token
         BOOST_SPIRIT_DEFINE(
         ^
main.cpp:226:9: error: ‘first’ was not declared in this scope
         BOOST_SPIRIT_DEFINE(
         ^

这是一个精灵:: x3错误?

1 个答案:

答案 0 :(得分:2)

两个变化:

  1. 添加遗漏的包含

    #include <boost/foreach.hpp>
    
  2. 选择“新风格”宏用法:

    BOOST_SPIRIT_DEFINE(expression , term , factor);
    
  3. 说实话,我不知道p = p_def样式初始化是可能的。我怀疑这是X3发布之前所需的语法。