Specifying the c++11 standard in Eclipse Luna [message #1770483] |
Sat, 12 August 2017 09:19  |
Eclipse User |
|
|
|
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 19:44  |
Eclipse User |
|
|
|
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: Mon, 14 August 2017 20:07] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.07588 seconds