1.What are the stages of compiling a C program?
Show hint
Think about what happens to #include lines, and what finally joins your code with printf.
Show solution
- Preprocessing expands
#include,#defineand#if(see it withgcc -E). - Compilation translates the C code to assembly (
gcc -S). - Assembly produces an object file of machine code (
gcc -c). - Linking combines object files and libraries into an executable.
A syntax mistake is a compiler error; calling a function that is declared but never defined is a linker error (undefined reference).