Headers and guards
A rover on a grid, split into rover.h and rover.cpp. What #include really pastes, a header read twice and the guard that stops it, and why a function body in a header needs inline.
Open it in the simulatorWhat happens between Run and the chip: one compile per file, a linker that joins them, headers with guards, macros and their traps, #if, extern and static, and build flags. Ends with one codebase that builds for an Uno and an ESP32-C3.
0 of 7 done
7 lessons in 4 chapters, about 5 hours on a simulated Arduino Uno R3. Free, in your browser, every step checked by the simulator.
A rover on a grid, split into rover.h and rover.cpp. What #include really pastes, a header read twice and the guard that stops it, and why a function body in a header needs inline.
Open it in the simulatorOne sketch, many builds: #if picks which lines the compiler ever sees. Debug lines that cost nothing when off, a version gate, the chip it was built for, and a default you can override.
Open it in the simulatorEvery Run hands the compiler a list of switches. Read their fingerprints from inside a sketch: the C++ standard, the chip, the optimizer, exceptions. Then a config header, and the linker throwing away code you never call.
Open it in the simulatorEach lesson opens when the one before it is done, and each chapter ends in a project.
Compile, link, and the headers that hold the promises.
What Run really does: preprocess, compile each file on its own, link them into one program. A declaration is a promise, a definition keeps it, and a second file joins the build.
0 of 5 steps
A rover on a grid, split into rover.h and rover.cpp. What #include really pastes, a header read twice and the guard that stops it, and why a function body in a header needs inline.
0 of 5 steps
Macros, their traps, and #if.
The preprocessor swaps text and knows nothing about C. A square that forgets its brackets, a maximum that reads a sensor twice, # and do-while(0), and when a function or constexpr does the job better.
0 of 6 steps
One sketch, many builds: #if picks which lines the compiler ever sees. Debug lines that cost nothing when off, a version gate, the chip it was built for, and a default you can override.
0 of 6 steps
extern, static, and the switches every build passes.
Who can see a name and how long it lives. A global another file reaches with extern, static at file scope that keeps a name private, and a static local that remembers between calls.
0 of 5 steps
Every Run hands the compiler a list of switches. Read their fingerprints from inside a sketch: the C++ standard, the chip, the optimizer, exceptions. Then a config header, and the linker throwing away code you never call.
0 of 5 steps
One codebase, two boards.
A beacon that builds unchanged for the Uno and the ESP32-C3. #if on the chip picks the pins, the sizes and a sum show what really differs, and a board.h keeps every difference in one place.
0 of 7 steps
All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.
Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.
Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.
See every kitYes. All 7 lessons of Multi-file C: headers, macros and builds are free and run in your browser, with nothing to install and no parts to buy before you start.
No. Every lesson runs on a simulated Arduino Uno R3 with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.
About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.
Each chapter ends in a project that puts it together: Headers and guards, Conditional compilation and Build flags.
With "Many files, one program", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.