Compiler
- A C/C++ compiler translates human-readable code (
.cpp, .h) into machine-readable object files (.o, .obj)
- A linker then combines these object files and external libraries into a final executable or library binary
- Major meta-build systems (like CMake) auto-detect these compilers natively on your system.
GNU Compiler Collection (GCC)
- Tools
- Default debugger
- Platforms supported
- Linux (native)
- macOS
- Windows (via MinGW-w64 or MSYS2)
- Known for
- robust optimization algorithms
- deep compliance with modern C++ standards.
Clang
- Tools
- Default debugger
- Platform supported
- Linux
- macOS (native)
- Windows (via native Clang-cl or MinGW-w64/MSYS2)
- Known for
- Extremely fast compile times
- user-friendly error/warning messages
Microsoft Visual C++ (MSVC)
- It is proprietary and developed by Microsoft
- Tools
- Default debugger
- Platform supported
- Known for
- Integrate flawlessly with Visual Studio IDE
Debuggers
- Debugging Symbols Format Standard:
DWARF: open standard used by GCC and Clang
PDB: Microsoft’s proprietary format used by MSVC
GNU Debugger (GDB)
- Tool:
gdb
- supports both
gcc (native) as well as clang compiled code
LLDB
- Tool:
lldb
- Part of LLVM project
- supports both
gcc as well as clang (native) compiled code
Visual Studio Debugger
- Microsoft’s proprietary, state-of-the-art graphical debugger
- Built directly into the Visual Studio IDE
- supports
cl.exe compiled code (native) as well as clang compiled code
Important Compiler Flags
Optimization Levels
-O0 (GCC/Clang) / /Od (MSVC)
- No optimization. Fast compilation, best for active debugging
-O2 (GCC/Clang) / /O2 (MSVC)
- Standard production optimization. Balances code speed and binary size
-O3 (GCC/Clang) / /Ox (MSVC)
- Aggressive optimization. Maxes out speed performance
-Os (GCC/Clang) / /O1 (MSVC)
- Optimizes specifically for the smallest possible binary size
Debugging and Warnings
-g (GCC/Clang) / /Zi (MSVC)
- Generates debug symbols (required for debuggers)
-Wall -Wextra (GCC/Clang) / /W4 (MSVC)
- Enables almost all compiler warning messages to catch bugs early
-Werror (GCC/Clang) / /WX (MSVC)
- Treats all warnings as errors, halting the build if any warning triggers
C++ Language Standards
-std=c++20 (GCC/Clang) / /std:c++20 (MSVC)
- Forces the compiler to use a specific C++ language edition