繁体   English   中英

使用gcc编译std :: regex_iterator

[英]Compile std::regex_iterator with gcc

我可以使用g ++ -c test.cpp -std = c ++ 0x创建.o文件,但无法链接它,得到下一个错误:

test.cpp:(.text+0xe5): undefined reference to `std::regex_iterator<char const*, char, std::regex_traits<char> >::regex_iterator(char const*, char const*, std::basic_regex<char, std::regex_traits<char> > const&, std::bitset<11u>)'
test.cpp:(.text+0xf1): undefined reference to `std::regex_iterator<char const*, char, std::regex_traits<char> >::regex_iterator()'

码:

#include <regex> 
#include <iostream> 

#include <string.h>

typedef std::regex_iterator<const char *> Myiter; 
int main() 
{ 
    const char *pat = "axayaz"; 
    Myiter::regex_type rx("a"); 
    Myiter next(pat, pat + strlen(pat), rx); 
    Myiter end; 


    return (0); 
} 

GNU C ++标准库支持<regex> ,但直到版本4.9.0 (标头出现在早期版本中,但无法使用。)

据我所知,其他编译器不支持它。

如果使用较旧的GCC,则可以使用其他库

暂无
暂无

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

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