This repository accompanies Why Learn C by Paul J. Lucas (Apress, 2025).
Download the files using the green button, or clone the repository to your machine using Git.
Releases are numbered using a form of semantic versioning except instead of major.minor.patch, edition.errata.patch is used instead where:
- edition corresponds to the edition of the published book, e.g., 1 = first edition, etc.
- errata corresponds to a correction mentioned in the errata for the published book.
- patch corresponds to an update only to the “support” files in this respository, but not in the published book, e.g., makefiles, Autoconf macros, Gnulib source files, etc.
For example, release 1.0 corresponds to the initial code in the first edition without corrections; release 1.0.1 corresponds to updates to command-line options in makefiles and Autoconf macros, but no corrections to the published book; etc.
Many of the C examples are compiled
and some are tested
to ensure they're syntactically
and semantically
correct.
A C compiler capable of compiling C23
via the -std=c23
option is required.
The git repository contains only the necessary source code.
Things like configure
are derived sources and
should not be included in repositories.
If you have
autoconf
,
automake
,
and
m4
installed,
you can generate configure
yourself by doing:
./bootstrap
or you can download a
released version
that contains configure
.
After that:
./configure
If you need to use a compiler
other than the first gcc
found in the PATH
environment variable,
specify it via CC
, e.g.:
./configure CC=clang
Finally, to build the source code for the larger examples:
make
If you get linker errors
like "undefined reference to __atomic_load
",
add LDFLAGS=-latomic
to your configure
command.
Optionally, you can also run unit tests for the larger examples:
make check
See the file
Contributing.md
for more information
on how you can contribute
to this repository.
See the file
Errata.md
for errata
to the published book.