Installing a C Compiler
Installing C means installing a toolchain such as GCC or Clang, using your system's package manager, and confirming it works with a version check.
Verify the compiler and choose an explicit language standard for a small program.
You have written the first line of the greenhouse logger, but the processor cannot read C. Before anything runs, something has to translate your text into machine code. Setting up C is really setting up that translator.
The rule
You don't install C — you install a compiler that speaks it.
C itself is a standard, a document published by ISO. What you install is a toolchain: a compiler, an assembler, a linker, and the headers and library files of the C standard library. The three toolchains you will meet most:
- GCC, the GNU Compiler Collection, standard on most Linux systems
- Clang, part of the LLVM project, standard on macOS
- MSVC, Microsoft's compiler, installed with Visual Studio on Windows
How to get one on each system:
# Debian or Ubuntu: GCC, make and the C library headers
sudo apt install build-essential
# Fedora
sudo dnf install gcc
# macOS: the Xcode command-line tools, which include Clang
xcode-select --install
# Windows, inside the MSYS2 terminal
pacman -S mingw-w64-ucrt-x86_64-gccOn Windows you can also install Visual Studio with its "Desktop development with C++" workload (MSVC handles C too), or use WSL to get a full Linux environment.
On macOS, typing gcc actually runs Clang. Apple sets it up that way so that build scripts expecting gcc still work.
Finally, tell the compiler which version of the language you mean. Default versions differ between compilers and even between releases of the same compiler, so this course builds with an explicit flag:
gcc -std=c17 -Wall -Wextra logger.c-std=c17 checks your code against C17. -Wall -Wextra switch on the most useful warnings. Despite its name, -Wall does not enable every warning, which is why -Wextra comes along. Clang accepts the same flags, so the command works whichever compiler you ended up with.