c++编译器在使用boost:: expression时给出了几页的警告

C++ compiler gives pages of warnings when using boost::xpressive

本文关键字:警告 几页 编译器 boost expression c++      更新时间:2023-10-16

当尝试使用boost::xpressive时,我得到了一长串编译警告;特别是当我使用sregex_compilercompile()函数时。

我按照文档编写了这个小程序:

#include <iostream>
#include <boost/xpressive/xpressive.hpp>
using namespace std;
int main (int argc, char **argv)
{
    bool matchResult;
    boost::xpressive::sregex_compiler compiler;
    boost::xpressive::sregex re;
    string str("hello world");
    re = compiler.compile("hello"); // <-- this line causes warnings
    matchResult = boost::xpressive::regex_search(str, re);
    cout << "match result = " << matchResult << endl;
    return 0;
}

当我编译时,我得到这一长串警告:

$ g++ -I /usr/local/include -o simple xpressive_simple.cc 
/usr/local/include/boost/xpressive/detail/core/matcher/alternate_matcher.hpp: In instantiation of 'boost::xpressive::detail::alternate_matcher<boost::xpressive::detail::alternates_vector<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >':
/usr/local/include/boost/xpressive/regex_compiler.hpp:284:   instantiated from 'boost::xpressive::detail::sequence<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_alternates(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:212:   instantiated from 'boost::xpressive::basic_regex<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::compile_(FwdIter, FwdIter, boost::xpressive::regex_constants::syntax_option_type, std::forward_iterator_tag) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:120:   instantiated from 'boost::xpressive::basic_regex<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::compile(InputIter, InputIter, boost::xpressive::regex_constants::syntax_option_type) [with InputIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:139:   instantiated from 'boost::xpressive::basic_regex<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::compile(const typename boost::iterator_value<Iterator>::type*, boost::xpressive::regex_constants::syntax_option_type) [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
xpressive_simple.cc:13:   instantiated from here
/usr/local/include/boost/xpressive/detail/core/matcher/alternate_matcher.hpp:88: warning: comparison between 'enum boost::xpressive::detail::alternates_vector<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::<anonymous>' and 'enum mpl_::size_t<1073741822ul>::<anonymous>'
/usr/local/include/boost/numeric/conversion/detail/meta.hpp: In instantiation of 'boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_signed> >':
/usr/local/include/boost/mpl/if.hpp:67:   instantiated from 'boost::mpl::if_<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_signed> >, boost::mpl::identity<boost::numeric::convdetail::subranged_SameSign<unsigned char, int> >, boost::mpl::eval_if<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned> >, boost::mpl::identity<boost::numeric::convdetail::subranged_Sig2Unsig<unsigned char, int> >, boost::mpl::if_<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, unsigned_to_signed> >, boost::numeric::convdetail::subranged_Unsig2Sig<unsigned char, int>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int> > > >'
/usr/local/include/boost/mpl/eval_if.hpp:37:   instantiated from 'boost::mpl::eval_if<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_signed> >, boost::mpl::identity<boost::numeric::convdetail::subranged_SameSign<unsigned char, int> >, boost::mpl::eval_if<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned> >, boost::mpl::identity<boost::numeric::convdetail::subranged_Sig2Unsig<unsigned char, int> >, boost::mpl::if_<boost::numeric::convdetail::equal_to<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, unsigned_to_signed> >, boost::numeric::convdetail::subranged_Unsig2Sig<unsigned char, int>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int> > > >'
/usr/local/include/boost/numeric/conversion/detail/meta.hpp:82:   instantiated from 'boost::numeric::convdetail::ct_switch4<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_signed>, mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, mpl_::integral_c<boost::numeric::sign_mixture_enum, unsigned_to_signed>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int>, boost::numeric::convdetail::subranged_Sig2Unsig<unsigned char, int>, boost::numeric::convdetail::subranged_Unsig2Sig<unsigned char, int>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int> >'
/usr/local/include/boost/numeric/conversion/detail/sign_mixture.hpp:63:   instantiated from 'boost::numeric::convdetail::for_sign_mixture<mpl_::integral_c<boost::numeric::sign_mixture_enum, signed_to_unsigned>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int>, boost::numeric::convdetail::subranged_Sig2Unsig<unsigned char, int>, boost::numeric::convdetail::subranged_Unsig2Sig<unsigned char, int>, boost::numeric::convdetail::subranged_SameSign<unsigned char, int> >'
/usr/local/include/boost/numeric/conversion/detail/is_subranged.hpp:164:   instantiated from 'boost::numeric::convdetail::get_subranged_Int2Int<unsigned char, int>'
/usr/local/include/boost/numeric/conversion/detail/is_subranged.hpp:186:   instantiated from 'boost::numeric::convdetail::get_subranged_BuiltIn2BuiltIn<unsigned char, int>'
/usr/local/include/boost/numeric/conversion/detail/is_subranged.hpp:208:   instantiated from 'boost::numeric::convdetail::get_subranged<unsigned char, int>'
/usr/local/include/boost/numeric/conversion/detail/is_subranged.hpp:227:   instantiated from 'boost::numeric::convdetail::get_is_subranged<unsigned char, int>'
/usr/local/include/boost/numeric/conversion/detail/conversion_traits.hpp:37:   instantiated from 'boost::numeric::convdetail::non_trivial_traits_impl<unsigned char, int>'
/usr/local/include/boost/numeric/conversion/conversion_traits.hpp:23:   instantiated from 'boost::numeric::conversion_traits<unsigned char, int>'
/usr/local/include/boost/xpressive/detail/dynamic/parse_charset.hpp:85:   instantiated from 'boost::xpressive::detail::escape_value<typename boost::iterator_value<Iterator>::type, typename CompilerTraits::regex_traits::char_class_type> boost::xpressive::detail::parse_escape(FwdIter&, FwdIter, CompilerTraits&) [with FwdIter = const char*, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:726:   instantiated from 'boost::xpressive::detail::escape_value<typename boost::iterator_value<Iterator>::type, typename RegexTraits::char_class_type> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_escape(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:522:   instantiated from 'boost::xpressive::detail::sequence<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_atom(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:589:   instantiated from 'boost::xpressive::detail::sequence<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_quant(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:622:   instantiated from 'boost::xpressive::detail::sequence<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_sequence(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:281:   instantiated from 'boost::xpressive::detail::sequence<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::parse_alternates(FwdIter&, FwdIter) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:212:   instantiated from 'boost::xpressive::basic_regex<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::compile_(FwdIter, FwdIter, boost::xpressive::regex_constants::syntax_option_type, std::forward_iterator_tag) [with FwdIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
/usr/local/include/boost/xpressive/regex_compiler.hpp:120:   instantiated from 'boost::xpressive::basic_regex<BidiIter> boost::xpressive::regex_compiler<BidiIter, RegexTraits, CompilerTraits>::compile(InputIter, InputIter, boost::xpressive::regex_constants::syntax_option_type) [with InputIter = const char*, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, RegexTraits = boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, CompilerTraits = boost::xpressive::compiler_traits<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > >]'
<snipped>
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:90:   instantiated from 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match(boost::xpressive::detail::match_state<BidiIter>&, const Next&) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<true>, boost::xpressive::detail::basic_chset<char> > >, Greedy = mpl_::bool_<true>]'
/usr/local/include/boost/xpressive/detail/dynamic/dynamic.hpp:80:   instantiated from 'bool boost::xpressive::detail::dynamic_xpression<Matcher, BidiIter>::match(boost::xpressive::detail::match_state<BidiIter>&) const [with Matcher = boost::xpressive::detail::simple_repeat_matcher<boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<true>, boost::xpressive::detail::basic_chset<char> > >, mpl_::bool_<true> >, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]'
xpressive_simple.cc:18:   instantiated from here
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:97: warning: comparison between 'enum boost::xpressive::detail::quant_style<quant_fixed_width, 1ul, true>::<anonymous>' and 'enum mpl_::size_t<1073741822ul>::<anonymous>'
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp: In member function 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match_(boost::xpressive::detail::match_state<BidiIter>&, const Next&, boost::xpressive::detail::greedy_slow_tag) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::basic_chset<char> > >, Greedy = mpl_::bool_<true>]':
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:90:   instantiated from 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match(boost::xpressive::detail::match_state<BidiIter>&, const Next&) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::basic_chset<char> > >, Greedy = mpl_::bool_<true>]'
/usr/local/include/boost/xpressive/detail/dynamic/dynamic.hpp:80:   instantiated from 'bool boost::xpressive::detail::dynamic_xpression<Matcher, BidiIter>::match(boost::xpressive::detail::match_state<BidiIter>&) const [with Matcher = boost::xpressive::detail::simple_repeat_matcher<boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::basic_chset<char> > >, mpl_::bool_<true> >, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]'
xpressive_simple.cc:18:   instantiated from here
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:97: warning: comparison between 'enum boost::xpressive::detail::quant_style<quant_fixed_width, 1ul, true>::<anonymous>' and 'enum mpl_::size_t<1073741822ul>::<anonymous>'
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp: In member function 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match_(boost::xpressive::detail::match_state<BidiIter>&, const Next&, boost::xpressive::detail::greedy_slow_tag) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<true>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, Greedy = mpl_::bool_<true>]':
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:90:   instantiated from 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match(boost::xpressive::detail::match_state<BidiIter>&, const Next&) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<true>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, Greedy = mpl_::bool_<true>]'
/usr/local/include/boost/xpressive/detail/dynamic/dynamic.hpp:80:   instantiated from 'bool boost::xpressive::detail::dynamic_xpression<Matcher, BidiIter>::match(boost::xpressive::detail::match_state<BidiIter>&) const [with Matcher = boost::xpressive::detail::simple_repeat_matcher<boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<true>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, mpl_::bool_<true> >, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]'
xpressive_simple.cc:18:   instantiated from here
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:97: warning: comparison between 'enum boost::xpressive::detail::quant_style<quant_fixed_width, 1ul, true>::<anonymous>' and 'enum mpl_::size_t<1073741822ul>::<anonymous>'
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp: In member function 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match_(boost::xpressive::detail::match_state<BidiIter>&, const Next&, boost::xpressive::detail::greedy_slow_tag) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, Greedy = mpl_::bool_<true>]':
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:90:   instantiated from 'bool boost::xpressive::detail::simple_repeat_matcher<Xpr, Greedy>::match(boost::xpressive::detail::match_state<BidiIter>&, const Next&) const [with BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, Next = boost::xpressive::detail::matchable_ex<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, Xpr = boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, Greedy = mpl_::bool_<true>]'
/usr/local/include/boost/xpressive/detail/dynamic/dynamic.hpp:80:   instantiated from 'bool boost::xpressive::detail::dynamic_xpression<Matcher, BidiIter>::match(boost::xpressive::detail::match_state<BidiIter>&) const [with Matcher = boost::xpressive::detail::simple_repeat_matcher<boost::xpressive::detail::matcher_wrapper<boost::xpressive::detail::charset_matcher<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> >, mpl_::bool_<false>, boost::xpressive::detail::compound_charset<boost::xpressive::regex_traits<char, boost::xpressive::cpp_regex_traits<char> > > > >, mpl_::bool_<true> >, BidiIter = __gnu_cxx::__normal_iterator<const char*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >]'
xpressive_simple.cc:18:   instantiated from here
/usr/local/include/boost/xpressive/detail/core/matcher/simple_repeat_matcher.hpp:97: warning: comparison between 'enum boost::xpressive::detail::quant_style<quant_fixed_width, 1ul, true>::<anonymous>' and 'enum mpl_::size_t<1073741822ul>::<anonymous>'

我在程序中做了什么导致这些警告显示?

编辑:我使用boost版本1.43和g++版本4.2.1。

Boost 1.47和g++ 4.4.3不会对您的代码给出任何警告,即使使用-Wall和-Wextra。最有可能的解释是您使用的boost版本较旧,并且自该版本发布以来,开发人员修复了许多警告。

也就是说,如果你(像我们一样)使用极端激进的警告级别进行编译,那么大量的boost仍然会产生很多警告。我们的解决方法是在g++中使用"警告抑制"头,看起来有点像这样:

#ifdef __GNUC__
#pragma GCC system_header
#endif
#include <boost/xpressive/xpressive.hpp>

我们通常将此文件放在名为nowarnings/boost/xpressive/xpressive.hpp的目录中,并包含该文件以抑制来自boost头的警告。