简体   繁体   English

Ubuntu上的regex错误

[英]Errors with regex on Ubuntu

I've a problem with using regex on Ubuntu,on Qt platform(I tried on Code::Blocks,too). 我在Qt平台的Ubuntu上使用正则表达式时遇到问题(我也在Code :: Blocks上尝试过)。 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): 当我键入#include <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. 而且我认为我应该使用Boost库。 I installed Boost with: 我安装了Boost:

sudo apt-get install libboost-all-dev

and typed(and I edited things,with writing boost:: in the beginning): 并键入(我编辑了东西,在一开始就写了boost:: :):

#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> . 您没有包括<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. 关于标准库提供的regex标头,错误消息说明了一切:您必须至少使用C ++ 11才能访问该标头。 Eg: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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