Master the fundamental concepts of c programming deep dive through this focused micro-challenge.
A C file on disk is not yet a running process. Clang (via the gcc driver) walks four stages that Make, CMake, and Bazel all assume you understand.
.c → .i): expand #include, #define, strip comments (gcc -E).i → .s): parse C, emit assembly (gcc -S).s → .o): machine code in a relocatable object (gcc -c).o → executable): resolve symbols across translation units (gcc file.o -o prog)Each .c file is its own translation unit. add.o can compile while main.o is untouched, which is why incremental builds work.
bashLoading…
"Undefined reference to foo" is a linker error: something declared, never defined in any .o. "Unknown type name" is a compiler error in stage 2.
For this exercise, you will run a small program with macros through all four stages and report what changed. This task asks you to connect error messages to stages, because debugging build failures without that map wastes hours in every systems shop.
Create a simple C program and demonstrate all four stages of compilation.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github