How can I configure VS Code to use the correct compiler path for C++ on macOS?

Question

Grade: Education Subject: Support
How can I configure VS Code to use the correct compiler path for C++ on macOS?
Asked by:
78 Viewed 78 Answers

Answer (78)

Best Answer
(423)
In VS Code, open the Command Palette (Cmd+Shift+P) and type 'C/C++: Edit Configurations (UI)'. This opens the `c_cpp_properties.json` file. Under 'Compiler Path', ensure the path points to the correct C++ compiler (usually `/usr/bin/clang++` or `/usr/bin/g++` if you've installed GCC via Homebrew). If using clang, make sure it's the correct version. You might need to specify 'intelliSenseMode' as 'clang-x64' or similar.