C++ 在自定义库中使用正则表达式时出错

C++ 在自定义库中使用正则表达式时出错,c++,regex,linux,compiler-errors,C++,Regex,Linux,Compiler Errors,我遵循这一点,一切都很好。现在我试着把这个函数rreplace像这样放在我自己的库中 myLib.h的内容 #include <regex> using namespace std; class myLib { private: // Some private things public: // Some public things int rreplace (char *buf, int size, regex

我遵循这一点,一切都很好。现在我试着把这个函数
rreplace
像这样放在我自己的库中

myLib.h的内容

#include <regex>

using namespace std;

class myLib {

    private:
        // Some private things

    public:
        // Some public things
        int rreplace (char *buf, int size, regex_t *re, char *rp);
};

我正试图用谷歌搜索它,但运气不好。如果问题太简单,我们深表歉意。

错误消息指出您需要使用选项
-std=c++0x
进行编译

g++ -std=c++0x -c myLib.cpp

请注意,您正在使用的desn编译器版本未附带正常工作的正则表达式实现。您可以使用不需要使用C++11选项编译的方法。

尝试
int myLib::rreplace(char*buf,int size,regex\u t*re,char*rp){}
您可能需要指定regex名称空间。我使用boost,并且通常在我的标题中添加类似的内容:
#include
使用namespace std
使用名称空间stdext
使用名称空间boost
In file included from /usr/include/c++/4.6/regex:35:0,
                 from myLib.h:4,
                 from myLib.cpp:1:
/usr/include/c++/4.6/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
In file included from myLib.cpp:1:0:
myLib.h:36:38: error: ‘regex_t’ has not been declared
myLib.cpp: In member function ‘void myLib::replaceDotsWithCommas()’:
myLib.cpp:18:2: error: ‘regex_t’ was not declared in this scope
myLib.cpp:18:10: error: expected ‘;’ before ‘re’
myLib.cpp:23:12: error: ‘re’ was not declared in this scope
myLib.cpp:23:38: error: ‘REG_ICASE’ was not declared in this scope
myLib.cpp:23:47: error: ‘regcomp’ was not declared in this scope
myLib.cpp: At global scope:
myLib.cpp:114:36: error: ‘regex_t’ has not been declared
myLib.cpp: In function ‘int rreplace(char*, int, int*, char*)’:
myLib.cpp:117:2: error: ‘regmatch_t’ was not declared in this scope
myLib.cpp:117:13: error: expected ‘;’ before ‘pmatch’
myLib.cpp:118:28: error: ‘pmatch’ was not declared in this scope
myLib.cpp:118:37: error: ‘regexec’ was not declared in this scope
myLib.cpp:122:9: error: ‘pmatch’ was not declared in this scope
myLib.cpp:131:8: error: ‘pmatch’ was not declared in this scope
myLib.cpp:132:49: error: ‘regexec’ was not declared in this scope
g++ -std=c++0x -c myLib.cpp