Reputation: 123
I am learning C++ and I am using Eclipse as an IDE. I downloaded the latest version for Mac (Version: 2018-12 (4.10.0)). I am trying uniform initialization but Eclipse gives me an error.
Here is the code:
#include <iostream>
int main()
{
int x{ 5 };
std::cout << x;
return 0;
}
If I type instead:
int x(5);
or
int x=5;
It works! The error shown is the following:
Building file: ../src/HelloWorld2.cpp Invoking: GCC C++ Compiler g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/HelloWorld2.d" -MT"src/HelloWorld2.o" -o "src/HelloWorld2.o" "../src/HelloWorld2.cpp" ../src/HelloWorld2.cpp:5:10: error: expected ';' at end of declaration
Any ideas?
Upvotes: 0
Views: 476
Reputation: 123
I couldn't find how to make Eclipse compatible for C++11, but then I found a website (took a while). Here is the solution.
There will be a field called 'Other flags' to the right of that list. Add the following (put a space at the end of the current text).
"-std=c++0x"
That's it!
Upvotes: 1