Lab 10 -- C Programming - Programming across files, Makefiles, Unit Testing
This page gives an overview of the lecture and the lab session on Oct 09, 2025.
Short lecture summary
-
Programming in multiple files and folders. Compilation and Linking. Functions of a linker. Header files and macros (
#ifndef,#endif). Creating libraries. -
Unit testing and need for unit testing. Demo for unit testing.
-
Using makefile. Writing makefile rules. Encoding dependency among programs across files in determining the order of compilation.
-
Using
realloc()and using it to build python list as a library in C.
Readings
-
Make files not war. Detailed write-up on makefile discussing many features that were mentioned in the class.
-
Understanding make files by Aniket Bhattacharyea.
-
Dive Into Systems by Suzanne J. Matthews, Tia Newhall, Kevin C. Webb (Online version)
Read chapter
-
Note for new make users by Alexander Gromnitsky.
Practise
-
Work out the makefile tutorial and check the makefile cookbook. Covers many features which did not cover in the class.
-
Work out the simple makefile tutorial.
Additional readings
-
On Multi-file projects by Beej.
-
Unit testing seen in the class is simple and does not use any special frameworks. However, there are frameworks like cunit, check and munit that can make testing easier.
-
Catastrophies from failure in writing test cases.
- Software error at Knight Capital - lack of testing and version control led to $440 million loss. The company was eventually acquired by their rivals.
- List of software bugs
- Ariane 5
- Mars Climate Orbitor
- Therac 25
