Tuesday, February 3, 2015

How to switch on C++11 on Eclipse?

This is, somehow, quite annoying me. I was compiling C++11 on Eclipse Kepler, but there was an error (as shown below) complaining to me that I must enable C++11 in order to proceed. But where is the C++11 switch?
Invoking: Cygwin C++ Compiler
g++ -I"D:\tool\boost_1_54_0" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.cpp"
In file included from /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/include/c++/initializer_list:36:0,
                 from ../src/main.cpp:6:
/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/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.
 #error This file requires compiler and library support for the \
  ^
In file included from D:\tool\boost_1_54_0/boost/filesystem/path_traits.hpp:23:0,
                 from D:\tool\boost_1_54_0/boost/filesystem/path.hpp:25,
                 from D:\tool\boost_1_54_0/boost/filesystem.hpp:16,
                 from ../src/main.cpp:7:
D:\tool\boost_1_54_0/boost/system/error_code.hpp:222:36: warning: 'boost::system::posix_category' defined but not used [-Wunused-variable]
src/subdir.mk:18: recipe for target 'src/main.o' failed
     static const error_category &  posix_category = generic_category();
                                    ^
D:\tool\boost_1_54_0/boost/system/error_code.hpp:223:36: warning: 'boost::system::errno_ecat' defined but not used [-Wunused-variable]
     static const error_category &  errno_ecat     = generic_category();
                                    ^
D:\tool\boost_1_54_0/boost/system/error_code.hpp:224:36: warning: 'boost::system::native_ecat' defined but not used [-Wunused-variable]
     static const error_category &  native_ecat    = system_category();

The switch was locate at project's properties > C/C++ Build > Settings > Tool Settings tab > Cygwin C++ Compiler > Miscellenous, put -std=c++11 in the Other Flags to switch on C++11 (append on it if it is not empty). Then the compilation will proceed as usual.

No comments: