I tried compiling the below program with "g++ -std=c++11 -o w w.cpp" and geting the error " cc1plus: error: unrecognized command line option "-std=c++11" ". Tried compiling with g++ -Dstd=c++11 -o w w.cpp and getting the below set of errors:
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:41,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stringfwd.h:42: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stringfwd.h:42: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:44,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:42,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef:49: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cstddef:49: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:42,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:65: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:65: error: expected unqualified-id before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:139: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:139: error: expected unqualified-id before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:245: error: ‘::wcstold’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:254: error: ‘::wcstoll’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:255: error: ‘::wcstoull’ has not been declared
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:260: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cwchar:260: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iosfwd:42,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:39,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:70: error: expected ‘{’ before ‘++’ token
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/postypes.h:70: error: expected unqualified-id before ‘++’ token
In file included from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ios:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/ostream:40,
from /usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/iostream:40,
from w.cpp:1:
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected ‘}’ before end of line
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/exception:35: error: expected declaration before end of line
program- w.cpp
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
int read_words(vector<string>& words, ifstream& in)
{
int i = 0;
while(!in.eof())
in >> words[i++];
return i-1;
}
int main()
{
ifstream ifp("names");
vector<string> w(500);
int number_of_words = read_words(w, ifp);
w.resize(number_of_words);
for(auto it : w)
cout << it << " ";
cout << endl;
map<string, string> wMap;
for(int i = 0; i < number_of_words;) {
wMap.insert(pair<string, string>(w[i], w[i+1]));
i += 2;
}
cout << "wMap.size()=" << wMap.size() << endl;
for(auto it = wMap.begin(); it != wMap.end(); it++)
cout << it->first << " " << it->second << endl;
}
gcc Version: gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3) g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
Please help me to sought out this issue.