Default c++ compiler version
I need to compile some small cpp files so I'd like to do that through the terminal. I'm using Catalina 10.15.5. I found out that macOS has a built-in clang compiler and I can use commands like c++
or g++
. It's version:
Apple clang version 11.0.3 (clang-1103.0.32.29)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
But I need to know which c++ version it uses (e.g. c++17, c++11 or even less version). It's really important for my files.
I know I can specify the version like c++ --std=gnu++17
but the question is how to make the compiler to use it by default (without aliases, there must be a command to change it). Or at least how to find out which version does it use right now?
Solution 1:
You can find the default version by looking in the manual:
man clang
It states:
The default C++ language standard is gnu++14.
This is basically the same as C++14, but with some GNU specific extensions.
The way to change the default setting when used "standalone" (i.e. without an Xcode project, Makefile or similar) is actually to make a shell alias. There's no clang
configuration file where you can change the default - you'll need to recompile the compiler to change it.