Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Eclipse with CDT doesn't accept C++11 features
Eclipse with CDT doesn't accept C++11 features [message #1714040] Mon, 09 November 2015 09:02 Go to next message
Eclipse UserFriend
Hello Community,

I'm using
Eclipse 3.8.1
CDT 8.0.2.201202111925
GCC 4.8.4
Ubuntu 14.04 LTS.

I want to develop in C++ but Eclipse doesn't want to accept C++ 11 features.
index.php/fa/23877/0/
Of course I read and made the steps described here http://wiki.eclipse.org/CDT/User/FAQ#CDT_does_not_recognize_C.2B.2B11_features.

index.php/fa/23876/0/
Project Properties > C/C++ Build > Settings > Tool Settings > GCC C++ Compiler > Miscellaneous

index.php/fa/23875/0/
Project Properties > C/C++ Build > GCC C++ Compiler > Compiler invocation arguments

index.php/fa/23874/0/
Window > Preferences > C/C++ > Indexer > [x] Index source and header files opened in editor

Also I added "__GXX_EXPERIMENTAL_CXX0X__" as described at stackoverflow. I cannot add the link because this is my first question in this forum.

index.php/fa/23881/0/
Project Properties > C/C++ General > Paths and Symbols > Symbols > GNU C++

but still I can't use C++ 11 features.

Can anybody tell me the missing adjustment?

Thanks in advance!
Boris Dockter
Re: Eclipse with CDT doesn't accept C++11 features [message #1714109 is a reply to message #1714040] Mon, 09 November 2015 18:15 Go to previous messageGo to next message
Eclipse UserFriend
You need to tell the indexer that you are using C++11 as well as the compiler. The Tool Settings tab only determines the options given to the compiler when building the make input files. You are using an older version of Eclipse/CDT but I see you found the command used to get the GCC default settings for C++11 scanning. The indexer seems to have a problem with several C++11 features and std::shared_ptr may be one of them. In fact, I think everything in <memorry> is a problem I submitted a bug report some time ago but can't remember the exact class and am too lazy too look it up. I had a problem when using <random> long ago that I was able to circumvent and never submitted a bug report. It may still exist.

As a test, you could try using some other C++11 constructs (such std::initializer_list) to see if they are OK.
Another might be for (auto ent : vec) but the syntax analyzer might accept that regardless of what the indexer thinks.

Along with syntax, another difference caused by using -std=c++11 (aka -std=c++0x) is that certain defines are set. Go to Project ==> C/C++ General ==> Preprocessor Include Paths, Macros, etc. (where it is in Mars, YMMV) and verify the following are set but I think __GXX_EXPERIMENTAL_CXX0X__ is the only important one for the indexer:

#define __cplusplus 201103L
#define __STDC_UTF_16__ 1
#define __STDC_UTF_32__ 1
#define __GXX_EXPERIMENTAL_CXX0X__ 1
#define __cpp_unicode_characters 200704
#define __cpp_raw_strings 200710
#define __cpp_unicode_literals 200710
#define __cpp_user_defined_literals 200809
#define __cpp_lambdas 200907
#define __cpp_constexpr 200704
#define __cpp_range_based_for 200907
#define __cpp_static_assert 200410
#define __cpp_decltype 200707
#define __cpp_attributes 200809
#define __cpp_rvalue_reference 200610
#define __cpp_variadic_templates 200704
#define __cpp_initializer_lists 200806
#define __cpp_delegating_constructors 200604
#define __cpp_nsdmi 200809
#define __cpp_inheriting_constructors 200802
#define __cpp_ref_qualifiers 200710
#define __cpp_alias_templates 200704
#define __GNUC_STDC_INLINE__ 1
#define __STRICT_ANSI__ 1

If they are set as above then the indexer should pick up C++11 declarations but, as I said, the indexer seems to have issues with <memory> and <random>.

Be aware that GNU had a phased approach to implementing features. I am using gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC) . Your earlier version my not handle certain C++11 constructs. See: https://gcc.gnu.org/projects/cxx0x.html although I think 4.8.1 and on have full support.

EDIT:
The problem with <memory>, in particular with unique_ptr and shared_ptr, seems to have been resolved with CDT 8.8.0.2015

[Updated on: Sun, 13 December 2015 13:06] by Moderator

Re: Eclipse with CDT doesn't accept C++11 features [message #1726554 is a reply to message #1714109] Mon, 14 March 2016 11:29 Go to previous message
Eclipse UserFriend
Thank you very much for your detailed reply!
Indeed I could resolve the problems with Eclipse and C++ 11 by doing following steps:

  • remove Eclipse 3.8.1 through "sudo apt-get remove eclipse"
  • install Eclipse 4.5.1 together with CDT 8.8.0 manually (not with "sudo apt-get ...")
  • add compiler flag "-std=c++11" in Eclipse
Previous Topic:C++11 won't compile on Eclipse Mars
Next Topic:libhover support for /*******//** doxygen comment
Goto Forum:
  


Current Time: Thu Nov 06 17:14:31 EST 2025

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

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

Back to the top