Reputation: 11
I am using Eclipse Kepler for development of C++ , lately I have been working on C++11 , with earlier threads (C++11 full support on Eclipse) I have configured C++11 in Eclipse. But I am unable to compile a basic program :
#include <array>
#include <iostream>
int main()
{
std::array<int, 3> arr = {2, 3, 5};
}
Error : 1./usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. 2. ../src/HelloWorld.cpp:19:5: error: 'array' is not a member of 'std'
But when I run from command Prompt using " g++ -std=gnu++11 xyz.cpp " , it is compiling sucessfully .
Please Help me how do I make my eclipse Kepler work with C++11 .
Upvotes: 1
Views: 619
Reputation: 2863
Paolo M answer is correct in order to turn on c++11 on a per-project basis. You can also enable c++11 (or any standard) by default for all projects.
In Preferences > C/C++ > Build > Settings > 'Discovery' tab
Select your compiler (eg. CDT GCC Built-in Compiler Settings MinGW) and add the -std=c++11
option.
The result can looks like ${COMMAND} ${FLAGS} -std=c++11 -E -P -v -dD "${INPUTS}"
Upvotes: 3
Reputation: 12757
Right click on your project on Project Explorer -> Properties -> C/C++ Build -> Settings.
In the Tools settings tab, there is a GCC C++ Compiler item. Expand it and select Settings -> Miscesllaneous.
Append at the end of the Other Flags text input the string -std=c++11
This should be done for any configuration you need.
Upvotes: 3