Martin Kopecký
Martin Kopecký

Reputation: 1010

Eclipse CDT C++20 Support

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

Upvotes: 5

Views: 3302

Answers (2)

Scott Milella
Scott Milella

Reputation: 487

There is a way now as I just enabled it and confirmed it.

To enable C++ v20 in Eclipse on a per project basis (I haven't yet been able to figure out how to make it a default for ALL projects) you will want to do the following in Eclipse:

To enable C++ v20 for a specific project you right click on your project and go to Properties > C/C++ Build > Settings > GCC C++ Compiler > Miscellaneous and in the box for Other Flags add "--std=c++20" to the end of it.

You can verify it with this code:

 #include <iostream>
using namespace std;

int main() {

     if (__cplusplus == 202002L)
                 std::cout << "Your running C++20" << endl;
              else if    (__cplusplus == 201703L)
                  std::cout << "Your running C++17" << endl;
              else if (__cplusplus == 201402L)
                  std::cout << "Your running C++14" << endl;
              else if (__cplusplus == 201103L)
                  std::cout << "Your running C++11" << endl;
              else if (__cplusplus == 199711L)
                  std::cout << "Your running C++98" << endl;
              else
                  std::cout << "pre-standard C++" << endl;

    return 0;
}

To enable the same thing on Visual Studio Code this URL was able to help me get it done:

https://www.youtube.com/watch?v=Mw7Jfzavx0U

If someone out there knows how to make this a default for ALL C/C++ projects I would love to know how. (still looking, will come back and update if I find the answer to this).

Here is a pic of my Eclipse terminal window showing the C++ v20 is active: enter image description here

Upvotes: 0

greywolf82
greywolf82

Reputation: 22173

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.

Upvotes: 3

Related Questions