3

I'm trying experiment with regex. So i created a project in VS 2010, and at the top i put:

#include "std_lib_facilities.h"
#include <regex>
using namespace std::tr1;

int main()
{
    regex rx("123");
    cout << ">";
    string s;
    getline(cin,s);
    regex_match(s.begin(),s.end(),rx);
    cout << '\n' << s << endl;
    keep_window_open();
}

When I compile I get a list of errors, it looks like there is a problem with the regex.h file itself. Here are the errors:

Error   1   error C2977: 'Vector' : too many template arguments c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    982
Error   2   error C2146: syntax error : missing ';' before identifier '_MyCont' c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    982
Error   3   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    982
Error   4   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    982
Error   5   error C2653: '_MyCont' : is not a class or namespace name   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    986
Error   6   error C2146: syntax error : missing ';' before identifier 'const_iterator'  c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    986
Error   7   error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    986
Error   8   error C2868: 'std::tr1::match_results<_BidIt,_Alloc>::const_iterator' : illegal syntax for using-declaration; expected qualified-name   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    986
Error   9   error C2146: syntax error : missing ';' before identifier '_Matches'    c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    1195
Error   10  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    1195
Error   11  error C4430: missing type specifier - int assumed. Note: C++ does not support default-int   c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    1195
Error   12  error C1903: unable to recover from previous error(s); stopping compilation c:\program files (x86)\microsoft visual studio 10.0\vc\include\regex    1428

How do I fix this and get the program running? Thanks

Richard
  • 5,840
  • 36
  • 123
  • 208
  • 2
    Your problem lies inside #include "std_lib_facilities.h". Remove this and keep_window_open(); and see it working :) – FailedDev Dec 02 '11 at 21:19
  • We may need to see the contents of this "std_lib_facilities.h" header file. It is possible that junk content in this file trigger compilation errors that end up being reported in "regex". – ZeRemz Dec 02 '11 at 21:22
  • @Richard Check my answer. You *may* need this for later use. So it would probably be better to solve this problem now :) – FailedDev Dec 02 '11 at 21:25

0 Answers0