How to get a C++17 environment on macOS High Sierra?

Viewed 2347

macOS High Sierra and Xcode 9 come with an old version of LLVM. It's not obvious which version of LLVM it is because of version number mangling. However, it's apparent it's old as the latest version of LLVM supports C++17 but features like std::optional are not available.

I'd like to write some C++17 code using a Mac. What toolchains are available and what has the fewest complications to get working? My thoughts so far:

  • LLVM via Homebrew -- interference with/by Xcode?
  • GCC via Homebrew
  • Above compiled from source

Any preferred method?

1 Answers

This 'answer' is not an answer to your question. These are the handy bookmarks I use.

I'd use Homebrew to install clang++ (see link below). But if you really want Xcode to interop with it, I'd suggest the "bad news" of wait for Apple, or try out their latest beta. And keep in mind that Apple's "Objective-C++" (*.mm) probably requires Apple's secret sauce, if you have some sort of C++ / Cocoa project.

C++17 implementation status:

Xcode -to- CLang version:

Homebrew to get CLang (clang++):

Related