Sorry for writing this shitty guide but it’s an issue that doesn’t seem to be answered on the internet, and I really needed a recent version of clang++ on macOS for a new job. Feel free to make fun of me if there is an easier way to do it.

  1. Install Nix (usually used for reproducible builds but you can use it too for virtual environments): https://nixos.org/download.html#nix-install-macos

  2. Create a file called shell.nix at the root of your project, and put the following code inside:

{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    nativeBuildInputs = with pkgs.buildPackages; [ llvmPackages_16.clangUseLLVM ];
}
  1. Run nix-shell

  2. Check that you have the good version with the command clang++ -v

It’s not a perfect solution, but it’s mostly automated, you’ll be able learn various topics of C++20 with this, and the stupid “clang 11” from Apple is not hijacking the latest version anymore.

No comments yet!

C++

!cpp@programming.dev

Create post

The center for all discussion and news regarding C++.

Rules

  • Respect instance rules.
  • Don’t be a jerk.
  • Please keep all posts related to C++.

Community stats

  • 32

    Monthly active users

  • 264

    Posts

  • 537

    Comments