简体   繁体   中英

Errors with regex on Ubuntu

I've a problem with using regex on Ubuntu,on Qt platform(I tried on Code::Blocks,too). I'm writing console application code and I must use regex.

When I typed #include <regex> ,It to me that error(I think it's the most important error,but there are many errors of regex):

/usr/include/c++/4.9/bits/c++0x_warning.h:32: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^

And I thought that I should use Boost library. I installed Boost with:

sudo apt-get install libboost-all-dev

and typed(and I edited things,with writing boost:: in the beginning):

#include <boost/regex.hpp>

But,unfortunately,It caused many errors,Like that:

In function `bool boost::regex_search<__gnu_cxx::__normal_iterator<char const*, std::string>, char, boost::regex_traits<char, boost::cpp_regex_traits<char> > >(__gnu_cxx::__normal_iterator<char const*, std::string>, __gnu_cxx::__normal_iterator<char const*, std::string>, boost::basic_regex<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::_match_flags)':

I'm really puzzled what I should to do.

You did not include the error message produced by <boost/regex.hpp> . Regarding the regex header provided by the standard library, the error message says it all: You have to use at least C++11, to have access to that header. Eg:

g++ -std=c++11 -Wall -Wextra -Werror foobar.cpp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM