C/C++¶
I loved C++ more than any other programming language during my undergraduate days1. I did also happen to have used C quite a lot too, since it was the first language I properly learnt during my FIC days and in my first semester in undergrad (I also had a bloody tough Operating Systems mod whose C programming assignments were challenging with a C99 GNU GCC compiler).
However, at the time of writing out this guide, I can admit that I am very rusty especially since graduating I spent a whole lot more time with general web development languages, Java to some extent again during my first teaching stint2, and now Python at my current role as a TA at NUS. However, now that I'm in the midst of auditing several courses in NUS, I felt like it'd do me good if I refreshed myself in the skill and brush up on my DSA skills. This is a golden opportunity, given the prof I was working under happens to have had frequently taught the C++ variant of the DSA module in NUS3 - and I was successful in being able to use his material to help with my learning.
This is probably going to be one of those serving more as reminders for me on how to set things up on my machine, rather than it be a general guide for everyone else (although if it makes it to that level, I'll be impressed lol).
GCC Compiler¶
I think this part alone is how I feel this guide will never feel complete - there are several kinds of C/C++ compilers, it's unrealistic for me to daily drive multiple kinds frequently. For now, I'm just sticking with the GNU GCC compiler (installed using Homebrew) as the compiler of my choice on my macOS machine4 in contrast to the Clang compiler that comes ready with XCode Command Line Tools. I believe there's also an option to download it from GNU's website too, if you prefer doing that instead.
brew search gcc # search up available formulae with "gcc" in the name
brew install gcc@15 # replace gcc@15 with the most recent version
From here, I turned to K0nze's guide to configure an easier way to use it in the Terminal. Put simply, it involved creating some environment variables as aliases that can be called instead of specifying the full path of where the GCC compiler was installed at.
export CC="$(brew --prefix gcc@15)/bin/gcc-15" # use "$CC" instead of "gcc" when compiling
export CXX="$(brew --prefix gcc@15)/bin/g++-15" # use "$CXX" instead of "g++" when compiling
source ~/.zshrc
Verify Installation¶
I decided to leave gcc be for Apple's Clang compiler - previously I would often try to symlink this with Homebrew's GCC compiler, and it'd break every now and then especially when there are new versions available.
As is, the created environment variables will suffice.
You can verify that everything works as intended by typing the following in the Terminal:
You should see something like as follows:

-
Granted, I did not spend a lot of time with it during then - I only used it in two mods:
- my Data Structures and Algorithms mod in Y2S1 (albeit only procedurally, it's like an easier way to present C implementations); and
- in an OOP using C++ mod in Y2S2 (had a lecturer with quite the obsession with short quizzes that tested menial memory work more than actual lab exercises, this trait was very apparent when I became his colleague 3 years later and observed how he handled a Python programming mod).
I did purchase Udemy courses for C++ (not sure if I would finish), as well as for C (I finished the beginner course, still have yet to finish the advanced one). ↩
-
I did also have plans on incorporating some optional programming exercises as part of the Introduction to Computing module for Taylor's FIC students - the same way how I spent my second half of my FIC days and my first semester in undergrad properly learning C.. that did not come to fruition since I left for Singapore 1 year after I wanted to implement this idea. ↩
-
In NUS, as far as I am aware there are at least 3 different variants of DSA courses (as like with several other courses like CS1010).
- CS2040/C is taught using C++ to undergraduate students, typically only those in Computer Engineering or Information Security - this is the one Prof Alan Cheng (i.e., the prof I'm working with) happens to have taught alongside IT5001 since I got hired. For AY25/26 S2 though, Prof Steven Halim is in charge.
- CS2040/S is also taught using Java to undergraduate students, but typically taken by Computer Science - I believe its a rotation between Prof Steven Halim and a different prof I have yet to meet.
- IT5003 is the postgraduate equivalent, but taught in Python. Once again, for this one, Prof Steven Halim is in charge (and has been the only one so far I think).
It's interesting and surreal to be in a university environment which allows this, it also gives some insight concurrently as to how the profs conduct the classes and which aspects are prioritized. ↩
-
I believe in CS2040/C, Prof Alan mandates that the code works in Visual Studio (which means Microsoft's C++ compiler) for his practical exams. For some reason, I think it's a good thing his practical exams are now held in venue at NUS's programming labs, but it means that his students would need to be familiar with the interface and that tool. I can't imagine it'd be smooth sailing most if not all the time, given how huge Visual Studio is and the extra configurations to prevent students from cheating or going online.
This compiler is not available simply by downloading and using Visual Studio Code on any supported operating system. ↩