Module 10 of 11

Preprocessor, Headers & Build Tools

Lessons

About This Module

Every program so far has fit in a single file. Real C projects don't. This module covers the tools that let you split code across files and build it reliably, starting with the part of the compiler you have already been using without noticing.

It begins with the preprocessor: #include pulls in other files, #define creates constants and macros, and conditional directives such as #ifdef choose what gets compiled. It then shows how to organize code into header files and source files, with include guards to prevent double inclusion, and ends with make, which rebuilds only what has changed.

Watch the lessons in order, then continue on to Debugging, Testing & Concurrency.

Lessons

6 videos
01

C Preprocessor Directives

A beginner's guide to the preprocessor, covering #include, #define, #ifdef, and #ifndef.

02

Preprocessor and Macros

Programiz's lesson on the preprocessor and macros, which you have been using every time you write #include.

03

Multiple Files, Headers & Compilation

How to split your code into .c and .h files, use header files to share functions across files, and compile a multi-file program.

04

Header Files, Include Guards & Object Code

A tutorial on modularizing a C program: why to split it into many files, what a module is made of, defining a .h header file, include guards, and incremental compilation.

05

Beginner Makefile Tutorial

A video on the basics of how make works. Once you understand this, the rest of Makefiles is much easier to follow.

06

Makefile Tutorial

An introduction to the make build system, going over the fundamental make commands using C or C++.