簡體   English   中英

Ubuntu上的regex錯誤

[英]Errors with regex on Ubuntu

我在Qt平台的Ubuntu上使用正則表達式時遇到問題(我也在Code :: Blocks上嘗試過)。 我正在編寫控制台應用程序代碼,並且必須使用正則表達式。

當我鍵入#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 \
  ^

而且我認為我應該使用Boost庫。 我安裝了Boost:

sudo apt-get install libboost-all-dev

並鍵入(我編輯了東西,在一開始就寫了boost:: :):

#include <boost/regex.hpp>

但是,不幸的是,它引起了很多錯誤,例如:

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)':

我真的不知道該怎么辦。

您沒有包括<boost/regex.hpp>產生的錯誤消息。 關於標准庫提供的regex標頭,錯誤消息說明了一切:您必須至少使用C ++ 11才能訪問該標頭。 例如:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM