Change clang default c++-version (mode)

2.4k Views Asked by At

I want to regularly compile C++20 code, using clang.

In the clang command guide (https://clang.llvm.org/docs/CommandGuide/clang.html) it says that I can add a flag (in my case: -std=c++2a) every time I want to compile something.

In the clang user manual (https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes) it states:

If no -std option is specified, clang defaults to gnu17 mode. Many C99 and C11 features are supported in earlier modes as a conforming extension, with a warning.

But is there a way to permanently change the default mode (i.e. c++-version) that clang uses?

1

There are 1 best solutions below

1
On

you can use an alias to do that although I won't recommend that.

alias g++='g++ -std=c++20'