Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Specifying the c++11 standard in Eclipse Luna
Specifying the c++11 standard in Eclipse Luna [message #1770483] Sat, 12 August 2017 13:19 Go to next message
Victor Doors is currently offline Victor DoorsFriend
Messages: 3
Registered: August 2017
Junior Member
I would like to use new features of C++11 but it is not working.
I have the gcc and g++ version 6 installed.
This is the code I am using to check if the C++11 feature are working:
#include <iostream>
#include <chrono>

//using namespace std;

int main() {
	using namespace std::chrono;

	return 0;
}


I modified already the Eclipse setting following some posts:
* For the compiler itself, I did the following:
1) Right click on the project->C/C++ Build->Settings->Cross GCC Compiler-> Dialect
2) In the "Language standard" drop-down menu I selected: ISO C11(-std=c11)
3) Close everything
4) Right click on the project-> C/C++ General->Preprocessor Include Paths, Macros etc. Providers-> CDT GCC Built-in Compiler Settings
5) Uncheck "Use global provider shared between projects"
6) In the Command to get compiler specs:", append "-std=c++11" after ${FLAGS}
7) Move the "CDT GCC Build-in Compiler Settings" entries to the top
8) Apply and OK

* for the indexer, I did the following:
1) Right click on the project-> C/C++ General-> Indexer
2) Check "Index all header variants" and "Index source and header files opened in editor"

* Finally I refreshed the Indexer and build the project:
1) Project->C/C++ Index->Re-resolve Unresolved Includes
2) Project->C/C++ Index-> Rebuild
3) Build the project

---- This are the outputs of my Eclipse console ----
make all
Building file: ../src/testFinal1.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/testFinal1.d" -MT"src/testFinal1.d" -o "src/testFinal1.o" "../src/testFinal1.cpp"
../src/testFinal1.cpp:10:20: fatal error: chrone.h: No existe el archivo o el directorio
#include <chrone.h>
^
compilation terminated.
make: *** [src/testFinal1.o] Error 1

Observation1: I only have the includes related with the version 6
Observation2: I don't see the -std=c++11 flag on my command, although I set it in my Eclipse Compiler Setting :(.
Any ideas?
Re: Specifying the c++11 standard in Eclipse Luna [message #1770608 is a reply to message #1770483] Mon, 14 August 2017 23:44 Go to previous message
David Vavra is currently offline David VavraFriend
Messages: 629
Registered: October 2012
Senior Member
Hi, Victor

Luna is three releases old.
The current is Oxygen with the latest CDT.
Many CDT issues have been fixed.
You should consider using it or at least upgrading to the latest CDT.

The error is saying that chrono.h can't be found.
Does it exist?
It also says it was included at line 10 but that doesn't match the code you provided.
I wonder why it is looking for chrono.h as the GNU file is /usr/include/c++/<gcc version>/chrono
The text of the line with the error is #include <chrone.h> which doesn't match your code.

Typically, g++ flags dialect problems with (using <random> as a C++11 example):
In file included from /usr/include/c++/6.3.1/random:35:0,
                 from ../src/Hello.cpp:18:
/usr/include/c++/6.3.1/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
 

amd/or
../src/Hello.cpp:35:6: error: 'mt19937' in namespace 'std' does not name a type
 std::mt19937 rng;



I don't see an indexer problem but if you are using the cross compiler you should use the cross compiler builtin provider settings.

You seem to have made the proper changes but be sure you are using the intended toolchain.

The make file may not have been rebuilt after changing the dialect.
Try cleaning the project then rebuilding.
If you must, delete the the configuration directories (typically, Release and Debug) then rebuild.




[Updated on: Tue, 15 August 2017 00:07]

Report message to a moderator

Previous Topic:CDT Process Type: ADDFILES
Next Topic:failed to install CDT package from downloaded zip
Goto Forum:
  


Current Time: Mon Dec 18 01:35:25 GMT 2017

Powered by FUDForum. Page generated in 0.02056 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software