Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change clang default c++-version (mode)

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?

like image 339
Jere Avatar asked Dec 10 '25 00:12

Jere


1 Answers

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

alias g++='g++ -std=c++20'
like image 165
Rishabh Deep Singh Avatar answered Dec 11 '25 13:12

Rishabh Deep Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!