thecodex.expert · The Codex Family of Knowledge
C

Setup and Compilers

Unlike many modern languages, there’s no single official C toolchain — GCC and Clang are both free, both excellent, and both widely used in production.

C17 / C23 GCC or Clang Last verified:
Canonical Definition

GCC, part of the GNU Project since the late 1980s, and Clang, built on the LLVM compiler infrastructure and known for clearer error messages, are the two dominant free C compilers — both are genuinely production-grade, used to build everything from the Linux kernel to major commercial software. macOS ships Clang (via Xcode's command-line tools); Linux distributions typically ship GCC by default, though both are installable everywhere. There is no single official reference implementation the way many newer languages have.

Compiling and running by hand

-o names the output executable explicitly; without it, both compilers default to a.out (a historical name dating back to early UNIX assemblers).

Cterminal
$ gcc hello.c -o hello    // compile with GCC
$ ./hello
Hello, World!

$ clang hello.c -o hello   // or compile with Clang instead — same source, either works

Enabling warnings: -Wall -Wextra

C's default warning level is famously permissive — code with genuine bugs (an uninitialized variable, a mismatched printf format specifier) often compiles silently without these flags. Enabling them is close to universal practice in real C projects.

Cterminal
$ gcc -Wall -Wextra -o hello hello.c
// -Wall: enables most commonly useful warnings
// -Wextra: enables additional warnings -Wall doesn't cover

Choosing a language standard explicitly

Without an explicit standard flag, the compiler's default can vary by version and vendor — specifying one directly makes a build's behavior predictable and portable across different machines and compiler versions.

Cterminal
$ gcc -std=c17 -Wall -Wextra -o hello hello.c   // target the C17 standard explicitly

Sources

1
Free Software Foundation. Using the GNU Compiler Collection, gcc.gnu.org/onlinedocs, and the Clang User’s Manual, clang.llvm.org/docs.