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.
- A first program and what
mainreturns -
#include <...>vs#include "..." - Comment syntax
- 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.
-
auto -
static -
extern -
register - Thread storage (
_Thread_local) - Qualifiers:
const,volatile,restrict,_Atomic
- Arithmetic operators
- Logical operators
- Bitwise operators (
& | ^ ~ << >>) - Comparison operators
- Ternary operator (
?:) -
sizeofoperator (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.
- if/else
- switch (and how jump tables may work)
- for, while, do-while
- goto and labels
- 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 (
inlinekeyword) - Variadic functions
- Using
gccproperly - Multi-file compilation
-
makebasics
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.
Small complete programs that use the whole of this phase at once rather than one topic at a time.