liveBook · Manning

Compiler

As explained in Modern C, Third Edition

A compiler implementation is the concrete software realization of a compiler that translates source programs according to a language's rules.

A compiler translates C source text into executable binary code that a particular machine can understand. C therefore mediates between programmer-readable instructions and platform-specific machine needs. section 1.2 section 1.3

The compiler is a tool rather than a language feature: its command name and options depend on the platform. The bundled translation process may include textual replacement, compilation, and linking. section 1.2 section 1.3

A compiler also helps establish whether a program satisfies C’s requirements:

  • Reports warnings and errors for invalid or questionable constructs; diagnostics should be treated as actionable evidence rather than ignored output. section 1.3
  • Targets different architectures while allowing one correct C program to remain portable across platforms. section 1.2
  • Does not guarantee portability merely because a program runs on one platform; implementations may fail to conform or accept nonportable extensions. section 1.2

Compiling and diagnosing a C program

A POSIX-style command such as `c17 -Wall -o getting-started getting-started.c -lm` translates a source file into an executable. Compiling flawed code with GCC reports an incorrect `main` return type, an undeclared `printf`, and an invalid return value; Clang reports corresponding errors. Correct the first diagnostic, recompile, and continue until the program is flawless. section 1.3

How Modern C, Third Edition covers it

How deep it goes
Defines translation, platform dependence, diagnostics, and portability but defers the internal mechanics of compilation.
Examples
Uses GCC and Clang diagnostics, compilation commands, and a flawed C program corrected through successive recompilation.
What it assumes
Assumes basic C source text and command-line access while introducing compilation, executable code, platform dependence, and compiler diagnostics.
What you can do after
Operate a C compiler, compile source files, interpret diagnostics, and iteratively repair programs toward portability.
How it connects
Connects C with executable code, machine and assembly language, linking, platform dependence, standards conformance, and portability.

Also explained in

Compare how 9 books explain compiler →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.