|
| Re: Eclipse with CDT doesn't accept C++11 features [message #1714109 is a reply to message #1714040] |
Mon, 09 November 2015 18:15   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.24158 seconds