There are many things that I find missing in default C++ build in Mac Sublime Text(clang) like no bits/stdc++.h header, regular warnings on using auto keyword, using inline comparator functions etc. So I tried searching how to use brew's g++ as default build in Sublime Text without breaking anything but couldn't find anything.
First of all install brew from brew.sh.
After that install gcc using the command in terminal 'brew install gcc'.
Check if install is complete using command 'gcc-11 --version' (I got gcc-11 installed, in future you may use gcc-12,gcc-13 etc).
Now type the command 'which g++-11' to get the location where g++-11 got installed. Copy this location ( Mine was something like — /opt/homebrew/bin/g++-11 ).
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give. Compiler-specific flags. Like any language server, clangd works on a per-file (or per-buffer) basis. But unlike most other language servers, it must also be aware of the exact compile flags that you pass to your compiler. For this reason, people have come up with the idea of a compilation database. Step 1: Download the.dmg file of Sublime Text from the official website just like we did for windows. Step 2: run and install the file and then you are ready to go. Now, you need to install the Gcc compiler on your mac. Run C in Sublime Text 3 on Mac OSX. I know there is a built in C compiler and run plugin for ST3. This builds my program just fine. Running the code, it runs the first part in its console, but stops at the first cin. The code runs fine when I run the file compiled in ST3 straight from the terminal.
Open sublime text and install 'PackageResourceViewer' from Package Control. After that open command palette and open 'PackageResourceViewer: Open resource'.
Then go to C++.
Sublime Text C
Then go to C++ Single file.
Finally replace all g++ with the location we copied earlier (/opt/homebrew/bin/g++-11).
Save this file using cmd+s and restart sublime text. Compile and build as you would usually do in sublime text (cmd+b/cmd+shift+b) and this time it would build using brew's g++.
Best C++ Compiler Mac
If you would like to revert back to original g++, just go back to C++ Single file build and change '/opt/homebrew/bin/g++-11' to 'g++' wherever applicable.
Sublime Text C++ Compiler Macro
Thanks