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?

  • 1
    The simplest command for a single file, e.g. foo.cpp is: clang++ -Wall -std=c++17 foo.cpp -o foo. For many .cpp files, a small makefile will be enough.
    – Yoan
    Commented Jun 12, 2020 at 12:16
  • @Yoan my purpose is to run several files during my exam to show that they at least compile. And I'm not allowed to write the next one before I finished the previous. So using the terminal is much easier and faster) Commented Jun 12, 2020 at 17:47

1 Answer 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.

  • And a makefile or an xcode project is much better than an alias for this. I would start with an xcode project
    – mmmmmm
    Commented Jun 12, 2020 at 10:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .