I installed boost recently, and I experimented with the Spirit library. I made a simple example that analyzes a comma-separated list of numbers and adds them together. The program compiled, but my compiler (VS 2013) issued multiple warnings. Look at the source:
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <iostream>
#include <string>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <iostream>
#include <string>
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
namespace phoenix = boost::phoenix;
using qi::double_;
using qi::_1;
using ascii::space;
using phoenix::ref;
template <typename Iterator>
bool adder(Iterator first, Iterator last, double& n)
{
bool r = qi::phrase_parse(first, last,
(
double_[ref(n) = _1] >> *(',' >> double_[ref(n) += _1])
)
,
space);
if (first != last)
return false;
return r;
}
int main()
{
std::string str;
std::getline(std::cin, str);
double result;
if (!adder(str.begin(), str.end(), result))
{
std::cout << "Invalid syntax." << std::endl;
}
std::cout << "The result is " << result << std::endl;
return 0;
}
This triggered 309 warning lines! They all looked something like this:
c:\boost\boost/spirit/home/support/terminal.hpp(264) : warning C4348: 'boost::spirit::terminal<boost::spirit::tag::lit>::result_helper' : redefinition of default parameter : parameter 3
c:\boost\boost/spirit/home/support/terminal.hpp(270) : see declaration of 'boost::spirit::terminal<boost::spirit::tag::lit>::result_helper'
c:\boost\boost/spirit/home/support/common_terminals.hpp(142) : see reference to class template instantiation 'boost::spirit::terminal<boost::spirit::tag::lit>' being compiled
The program compiled and did what I thought it would do, but I wonder how to manage all these warnings without silencing the useful ones. Is there a way to disable warnings that arise from boost, but keep warnings generated by my code? Spirit is a pretty popular library, so I know there is a way to deal with it.