Re: Linking error while separating parser into _def and .cpp files

Joel de Guzman <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 09/11/2016 6:30 AM, Exagon wrote:
> https://github.com/bitwalda/Spirit_X3_liker_error
> <https://github.com/bitwalda/Spirit_X3_liker_error>
> here is a githup repo with all the files in the wandbox

Here's the corrected code:

template<typename Parser>
bool test(std::string str, Parser&& p, bool full_match = true)
{
     using iterator_type = std::string::const_iterator;
     iterator_type in = str.begin();
     iterator_type end = str.end();
     std::string ast;
     bool ret = boost::spirit::x3::phrase_parse(in, end, p, 
boost::spirit::x3::ascii::space, ast);
     ret &= (!full_match || (in == end));
     return ret;
}

1) You declared std::string::const_iterator as your iterator. You need to
    make sure you give it the exact type. str.begin() does not give you that.
2) You declared an attribute of std::string. You did not pass any.
3) You passed boost::spirit::x3::space as your skipper, but you declared
    it as boost::spirit::x3::ascii::space. Those are different types.

You'll need to be very exact with what you declare and with what you
actually use. X3 allows any sort of possible types, but the linker does
not.

Here's a tip: When having linker errors, after BOOST_SPIRIT_INSTANTIATE,
declare something like:

   int x = context_type{};

It will be an error, yes, because context_type cannot be converted to
an int. But that error will also give you the exact type of your context.
Compare it against the linker error and you will see your mistake.

Once you get past this initial hurdle, it will be smooth sailing (apart
from the probable bug reported by Mikael, and we'll fix that ASAP).

Hope that helps.

Regards,
-- 
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.