Eclipse CDT C++20 Support - eclipse-cdt

is there a way to enable support of C++20 features in Eclipse 2020-03 (CDT 9.11)? I mean to get rid of incorrect syntax highlighting like igroring newly added keywords like 'concept', 'requires' and others as defined in C++20 standard? I have a GCC10 supporting those stuff installed and in usage, so the code is built without any troubles but Eclipse CDT still complains about it...
Thanks to anyone willing to advise. Martin

There's no support for C++20 in Eclipse CDT. Actually the support to C++17 is quite high but not totally completed yet. If you need C++20 support is better to use another IDE at the moment or implement the support in CDT if you want.

Related

How can Eclipse CDT Indexer be configured, in order to recognize all the new features in C++20 and above

Current version (2022-03 (4.23.0)) of Eclipse CDT indexer does not recognize new features which are included in C++20 and above, like Concepts.
This results in:
Not being able to view the keywords (and possibly other parts) of those features in highlighted mode.
While the compiler is OK with those features, Eclipse editor identify them as syntax errors where ever they are defined/declared and also mark them as errors (with a red line under them) where ever they are used
This is a similar question to Eclipse CDT Indexer does not fully recognize c++11
and Eclipse CDT indexer does not know C++11 containers
How ever the version of C++ is different and I have tested all of the suggestions in the answers for those questions and none of them worked for this particular case.
More over, I am after a more general solution. I also remember having a similar issue with a new C++ feature in an older Eclipse version, which was solved with the newer versions of Eclipse.
Considering this lag of conformity with new standards of the language, is there any solution/work-around which could potentially solve the issue from now on?
I also appreciate any solution for this particular case, C++ Constraints and concepts https://en.cppreference.com/w/cpp/language/constraints.

Can Eclipse be configured to support C++14?

Forgive me if this is trivial, but I'm trying to get back to C++ after a long time and am having trouble configuring Eclipse Oxygen 4.7.1a to support C++14. Is it possible to enable C++14 support in Eclipse at all?
The April 2017 Eclipse newsletter states that "CDT's support for C++14 is a work in progress", but I don't know if this still holds.
Here's what I tried. Under File → Properties → C/C++ Build → GCC C++ Compiler → Dialect, there's a built-in setting where I set Language standard to ISO C++1y (-std=c++1y), but this doesn't seem to help as even features such as std::shared_ptr are not recognized by Eclipse. I tried entering -std=c++14 into Other dialect flags, but to no avail. I also tried the proposed solutions in this answer, but again with no success.
I have gcc 5.4.0.
Is it possible to get C++14 working with Eclipse Oxygen?

Eclipse Luna Indexer for C++14 with custom makefile

I currently have a C++ project with a custom makefile. I tell eclipse to simply call make and the makefile handles everything. The project builds fine but eclipse keeps highlighting generalized lambda captures as "syntax errors". As far as I understand from this:
https://stackoverflow.com/a/835019/4076418 ,
it's a problem with the CDT Indexer not understanding the C++14 syntax.
I've tried following the answers here:
Eclipse CDT C++11/C++0x support
https://stackoverflow.com/a/13635080/4076418
but they don't handle my case which is Eclipse Luna + a custom makefile project + c++14.
This question is probably related to mine but it has no answer [I also don't have the ability to change the indexer]:
https://stackoverflow.com/q/24950192/4076418
Any ideas on how to get the indexer to recognize c++14 features?
P.S. C++11 features aren't highlighted as syntax errors for some reason. I should also note that I'm using clang 3.4.2 in the makefile; obviously, it supports c++14. The g++ version available though is 4.4.7 so it doesn't support c++14. Could this be the problem somehow? That the CDT uses the system's g++ for the indexer? And if so, how do I change that without having to update g++ (I'm working with limited user privileges and updating it would be a pain)?
AFAIK Eclipse Luna does not support C++14 overall. You will probably need to upgrade to Eclipse Neon. I use neon, the parser works, I don't use custom makefile though
I have used Luna in the past, but even C++11 support was sometimes hard to setup.

C++11 on Windows

I'm wondering how well writing software in C++11 works on Windows yet. It would be most comfortable (and propably most natural) to use one of the native compilers for Windows - I'm thinking about Visual Studio 2012 Express or Visual Studio 2013 Express here. Everything I could find so far on that matter is
http://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx
(Comparison of C++11 features of VC10 and VC11, which seems to be quite bad)
http://blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in-vs-2013.aspx (not really transparent, didn't give me a good idea how well it works)
Does anyone have any experience how well the current Visual Studio versions can handle C++11? I really want to start using auto, lambdas, variadic templates, template aliases, initializer lists and rvalue references (to name just a few) and all the other good stuff right now, but if Windows might be a problem I might have to use C++03 further.
Another possibility seems to be to install LLVM and Clang on Windows. My primary platform is OSX, and on that system Clang's support for C++11 is really good. But I read that the LLVM-version of the standard library for C++ (libc++) does not work well on Windows. So LLVM/clang might not be an option.
What are your opinions on C++11 development on Windows?
Thank you!
I can only give you my experience as a developer, as I've been building against the cutting edge of C++ on Windows using Visual C++ for just about everything, while also installing several other compilers and IDEs (including building Clang myself on Windows for Visual Studio 2012, 2012 CTP, and 2013 Preview). The following is my experience up until right now (August 13th, 2013), and is based on Herb Sutter's talk and working with the compiler every day.
The Quick
Run in the opposite direction of Visual Studio / VC++. Support for C++11 is slow, and they're currently being crushed in terms of compiler features versus Clang and GCC.
The Present
Visual C++'s C++11 (and C++14 support) is beyond abysmal right now. They lack powerful features that make template metaprogramming in C++ great (using expressions in particular).
Using doesn't exist right now. I have spent hours and hours porting great C++11 code with using to VC++, only to have it break it certain places, snap, or just become near damn unmaintainable.
Variadic support in the CTP was horrifically terrible, and while it got better for Visual Studio 2013 Preview's version of the compiler, it's still fairly bad at complex variadic and template expressions that obey the standard (and compile fine in GCC and Clang).
=delete and =default are pretty much gone from VC++ right now; in the hopeful near future, maybe it will work out (and it should come "soon-ish", according to the roadmap) (I had to implement r-value constructors explicitly for many simple classes all the way down a 8-class inheritance hierarchy once. It was the worst slap in the face, when I watched GCC and Clang users get all of my explicit hardcoded work for free with =default).
As a holdover (primarily because of Windows OS code and some binary compatabilities), Empty-Base-Class-Optomizations in VC++ don't work. Don't expect your class hierarchy sizes or member layout to be optimized in the least (watch your ordering in std::tuple when packing variable types).
This is about all the frustrations I've come into contact with so far. They're work-aroundable -- I have to work with them every day -- but if you want great C++ support, you should jump for GCC or Clang and somehow make it work on your machine.
The Future
If you really want C++11, you will need to wait about a year, and even then Visual Studio 2013's release of VC++ will still be missing a few features (and don't expect them to be bugless either). VC++ for 2013 will also still be critically missing std::move and explicit r-value support in many places, making it painful when you expect things to work.
The Caveat
If you're not a powerful Vim user, you're low on options when it comes to IDEs that you can work with (that play nice with GDB/GCC or Clang).
QtCreator is nice, works with MinGW, and is generally fully featured enough to get work done.
Sublime Text can be used, but you'll have to write your own building system or delegate that to something else.
Code::Blocks's autocomplete is wonky and behaves strangely, and the IDE itself feels clunky.
Eclipse is supposed to be good, but my experiences with it are clunky and strange, with odd input lags at time (despite a 8.00 GB i7 Haswell machine using an SSD).
Visual Studio, as an IDE, is pretty solid. Then stack Visual Assist X on top, and it works pretty damn well for C++ coding. It's really the only reason I continue to stick with it, but I've already made headway into learning Vim so I can mostly ditch Visual Studio altogether, when the time comes.
About Libraries
Library support in VC++ is pretty complete (for as much as their broken compiler lets them be complete). It has regex, while most other libraries have non-existent or broken regex support. But that doesn't mean that the VC++ library plays nice with some C++11 features that it says it does (picture by melak47).
And Lastly
If you want code that you know is going to work in Windows, 100%, for the rest of eternity, you'll probably want to program against VC++. The other "benefit" is that the code you write in VC++ is the smallest subset of C++/C++11 you can write with, so in the end it should compile everywhere. Of course, that goes against the very idea of using beautiful C++11 and enjoying it, so... pick your poison(s) wisely.
VC's C++11 support is far from complete, but it does include the most important user-facing features.
And here's the other thing. In my experience, it is fine to install MinGW or Clang on Windows, but you're going to have some inconvenience because hardly anybody precompiles binaries for those compilers for Windows (whereas lots of people precompile binaries for Visual Studio).
In addition, there are as far as I am aware no environments for Windows which are remotely as advanced as Visual Studio for things like graphical debugging, intellisense, and stuff like that. When I tried Code::Blocks it just didn't work, realistically.
You can see here for a comprehensive comparison of compiler support for C++11 language features. Here's some info on VS's C++11/14 roadmap.
MSVC is lagging behind the other major C++ compilers but it's still got support for many of the most important features.
auto, lambdas, and rvalue references are available from VS10. IIRC there's a caveat with rvalue references that the compiler doesn't generate move construction and move assignment operators.
variadic templates and initializer lists are available in the VS2013 preview, including library support.
type aliasing (i.e., typedefs with the using keyword) is expected to be available in VS 2013 RTM.
If you don't need to interoperate with binaries generated by VS then installing another compiler such as GCC is workable. I understand Clang can also work in a mingw environment, with libstdc++ rather than libc++.
http://nuwen.net/mingw.html
The nuwen distro is AWESOME! It is MinGW but it comes out much quicker than MinGW as new GCC releases come out. It also comes with all of boost and other useful libraries already compiled. It is all I use on windows anymore.
We are using C++11 for a few months already in production software across windows and linux in some here.com products without any problems. We use auto, lambdas, range for... Using Visual studio 2012 and gcc 4.7.
I have been using VS2012 and used C++11 features where possible. There are some bugs in the implementations and I have found it helpful to have another compiler to hand when I get errors from Visual Studio to compare against.
Clang and GCC to lead the way in terms of C++11 feature support and it appears to be a neck-and-neck race in terms of C++11 support between the two. MSVC is sadly panting trying to keep up and lagging behind. The Nuwen MingGW distro is, as Jake mentions, excellent and appears to be working well with Eclipse (Kepler release) and I didn't encounter too much pain using it with Netbeans 7.4 either. The Nuwen distro is currently at version 11.2 at the time of writing and, as you can see at Stephan's website, is now x64-native, featuring GCC 4.8.1 and Boost 1.54.0, with GCC's default mode also set to C++11.
I'm certainly beginning to use Eclipse Kepler and Nuwen MinGW in preference to MSVC 2012 more and more, but I'm largely a hobbyist C++ programmer still getting my feet wet and may not have hit the more obscure problems that those to whom C++ is their bread and butter may know about.

I'm having some trouble with C++11 in Xcode

I'm a Mac OS X Lion user who uses Xcode for C++, and it appears that no updates are available for Xcode. I do not appear to be able to compile C++11-exclusive code, but for whatever reason, I thought Apple had gotten C++11 pretty much implemented. And yes, I do have support for Command Line Tools.
Then again, that might just be me. If so, is there any sort of IDE that supports C++11, or any way to upgrade?
I use Xcode and set the following settings:
C++ language dialect: C++11 or GNU++11
C++ Standart Library: libc++ (LLVM C++ standart library with C++11 support)
Xcode version: 4.3.2
If you're using Xcode 4.3 there are several relevant project settings you need to use C++11 features. The first is to use the clang compiler. Something like
GCC_VERSION = com.apple.compilers.llvm.clang.1_0
in your .xcconfig will set it, or you can use the GUI.
Next, you need to tell LLVM which C++ standard to use:
CLANG_CXX_LANGUAGE_STANDARD = gnu++11
This will make language features like range based for, delegated constructors, etc. available.
Finally, if you want to use C++11 STL features (such as std::unordered_map) you need to use the libc++ STL:
CLANG_CXX_LIBRARY = libc++
On XCode 5 / opencv 2.4.9, I can select:
And it builds without error.
If i set the libc++ without specifying C++ Language Dialect then I get same issue as OP