Ccc / gccmakeIntermediate~5h

C Foundations

The C you need before pointers

Types that commit to a width and a sign, control flow that is integers underneath, arrays that lose their length at the door, and strings that end in a byte nobody counts. Then the four programs cc runs in a row, driven by hand, until a two-file build is something you did rather than something that happened.

Modules
6
Drills
15
Build steps
7
Time
~5h

Walk out able to

Say what a small C program prints before compiling it, and build one of your own from two source files, a header and a Makefile you wrote.

What you practise

01

Width, sign and what wraps

Sizing, bit patterns, conversions, masks and specifiers.

02

Flow that means it

Loop counts, fall-through, and conditions that lie.

03

Arrays, strings, functions

Indices that land, the plus one, and copies in and out.

04

The build, by hand

Four stages, four flags, two objects and one Makefile.

The pitch

What you practise, and what you leave with

A word-statistics program over a fixed text: two translation units, a shared header, a hand-run link, and a Makefile that rebuilds only what changed.

You will practise

  • Widths, signs, overflow, masks, specifiers
  • Loop counts, switch fall-through, false friends
  • By-value calls, array bounds, the terminator
  • Build stages, macros, and syntax at speed

Afterwards you can

  • Predict a small C program before compiling it
  • Stay inside an array and size a buffer right
  • Say which build stage a message came from
  • Link two objects by hand, then automate it

Modules

6 modules, 39 items

Lessons explain one idea. Drills repeat it until it sticks. Build steps make something that exists afterwards.

  1. 1

    Say how big and how signed

    ~1h

    Size a declaration, read a bit pattern, and predict what a conversion leaves behind.

    • LessonSee what this project is for5 min
    • LessonGive every value a size and a sign6 min
    • LessonName the three places a value changes6 min
    • DrillSize a declaration9 min
    • DrillRead a pattern as a signed value10 min
    • DrillWrap a fixed-width sum10 min
    • DrillCross a type boundary11 min
    • DrillMask and shift bits8 min
    • DrillMatch a specifier to its value7 min
  2. 2

    Say exactly what runs

    ~48 min

    Count a loop, follow a switch past a label, and see a condition that compiles and lies.

    • LessonRead a condition as a number6 min
    • LessonRecognise the three shapes that lie6 min
    • LessonRead a switch as a jump5 min
    • DrillCount a loop’s iterations10 min
    • DrillFollow a switch past its label10 min
    • DrillSpot the condition that lies11 min
  3. 3

    Declare it before you call it

    ~28 min

    Write a function, know what its parameters can and cannot touch, and give it a prototype.

    • LessonKnow what a function can reach7 min
    • LessonPut the prototype where it will be found6 min
    • LessonRecognise an implicit declaration5 min
    • DrillSay what the caller still holds10 min
  4. 4

    Stay inside the array

    ~28 min

    Index a fixed-size array safely, and get its length from the only expression that works.

    • LessonStay inside the last index7 min
    • LessonAsk an array how long it is5 min
    • LessonCarry the length across the door6 min
    • DrillLand the index inside the array10 min
  5. 5

    Count the terminator

    ~41 min

    Measure a string, size a buffer for one, and write C lines that compile first time.

    • LessonFind the byte after the text7 min
    • LessonSize a buffer with the plus one6 min
    • LessonCount what the text will be6 min
    • DrillCount the terminator10 min
    • DrillWrite the line that compiles12 min
  6. 6

    Drive the compiler yourself

    ~2h

    Stop the build after any stage, attribute a diagnostic, and ship a two-file program.

    • LessonTake the build apart7 min
    • LessonStop the build where you like5 min
    • DrillName the stage that refused8 min
    • DrillExpand a macro by hand9 min
    • Build stepGet a C compiler that answers6 min
    • Build stepStop the build four times13 min
    • Build stepCount the words in one file9 min
    • Build stepMeasure what you counted8 min
    • Build stepSplit it and link it yourself9 min
    • Build stepFill the histogram you promised8 min
    • Build stepWrite the build down10 min

Everything before the asterisk, and the build underneath it.

The first item is free. ~5h of focused work, at your own pace.

Intermediate~5h6 modules