Compilation Process in C
The computer cannot directly execute normal C source code. The source code goes through several stages before an executable program is produced.
- Source Code → The programmer writes a .c file.
- Preprocessing → #include, #define and other preprocessor directives are handled.
- Compilation → The C source is translated and checked for C language rules.
- Assembly → Assembly instructions are converted into object/machine code.
- Linking → Object code is combined with required library code to create an executable.
- Execution → The operating system loads and runs the executable.
Example GCC command
| gcc program.c -o program |
| ⭐ EASY TIP: If your program has a syntax error, compilation normally stops and the compiler reports the problem. Fix the error and compile again. |