Skip to content

Latest commit

 

History

History

phase-0-foundations

README.md

Phase 0 - Foundation Expansion

The basics that are easy to skip and expensive to skip. Work through this before or alongside Phase 1.

Run anything here with make run FILE=<path> from the repo root.

00-getting-started

  • A first program and what main returns
  • #include <...> vs #include "..."
  • Comment syntax

01-datatypes

  • Primitive types: int, char, float, double
  • Signed vs unsigned types
  • Short, long, long long
  • Fixed-width types: int8_t, uint32_t, int64_t
  • Boolean type (_Bool, <stdbool.h>)
  • Real meaning of char (signedness, ASCII)
  • Integer promotions
  • Usual arithmetic conversions
  • Type casting (implicit and explicit)
  • Why C is not type-safe

Note: primitive-types.c, initialization-forms.c and typedef-basics.c are declaration catalogues, so they compile with -Wunused-variable warnings on purpose.

02-storage-classes-and-qualifiers

  • auto
  • static
  • extern
  • register
  • Thread storage (_Thread_local)
  • Qualifiers: const, volatile, restrict, _Atomic

03-operators

  • Arithmetic operators
  • Logical operators
  • Bitwise operators (& | ^ ~ << >>)
  • Comparison operators
  • Ternary operator (?:)
  • sizeof operator (deep understanding)
  • Operator precedence and associativity

Still missing from this folder, and worth writing yourself: lvalues vs rvalues, modifiable vs non-modifiable lvalues, why a = b = c works, sequence points, and undefined behaviour from expressions.

04-control-flow

  • if/else
  • switch (and how jump tables may work)
  • for, while, do-while
  • goto and labels

05-functions

  • Function declaration vs definition
  • Return types
  • Parameter passing (by value vs by pointer)
  • The call stack, stack frames, return addresses (see phase 2)
  • Inline functions (inline keyword)
  • Variadic functions

06-build-system

  • Using gcc properly
  • Multi-file compilation
  • make basics

The root Makefile is the working example for this topic. Read it, then try writing a small one for a two-file program of your own.

practice

Small complete programs that use the whole of this phase at once rather than one topic at a time.