I experimented with some new C ++ 0x features with g ++. Lambdas, auto , and other new features worked like a charm, but the for-loop could not be compiled. This is the program I tested:
#include <iostream> #include <vector> int main () { std::vector<int> data = { 1, 2, 3, 4 }; for ( int datum : data ) { std::cout << datum << std::endl; } }
I compiled it with
g++ test.cpp -std=c++0x
I also tried gnu++0x , but the result was the same.
This was the result:
test.cpp: In function 'int main()': test.cpp:8:21: error: expected initializer before ':' token test.cpp:12:1: error: expected primary-expression before '}' token test.cpp:12:1: error: expected ';' before '}' token test.cpp:12:1: error: expected primary-expression before '}' token test.cpp:12:1: error: expected ')' before '}' token test.cpp:12:1: error: expected primary-expression before '}' token test.cpp:12:1: error: expected ';' before '}' token
Thanks in advance for your help.
EDIT: I am using GCC version 4.5.2, which I see is too old.
source share