Spirit X3: Unable to compile any example on Ubuntu 16.04
Can't compile example on 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(
^
is it an error: x3?
+3
source to share
1 answer
Two changes:
-
add missing include
#include <boost/foreach.hpp>
-
choose to use the "new style" macro:
BOOST_SPIRIT_DEFINE(expression , term , factor);
To be honest, I didn't know that style initialization was p = p_def
possible. I suspect this was the required syntax before X3 was released.
+2
source to share