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.

  1. Source Code → The programmer writes a .c file.
  2. Preprocessing → #include, #define and other preprocessor directives are handled.
  3. Compilation → The C source is translated and checked for C language rules.
  4. Assembly → Assembly instructions are converted into object/machine code.
  5. Linking → Object code is combined with required library code to create an executable.
  6. 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.
Scroll to Top