What happens when you type gcc main.c

How do we compile and run a C program?

$ gcc –Wall filename.c –o filename
  • The option -Wall enables all compiler’s warning messages. This option is recommended to generate better code.
    The option -o is used to specify the output file name. If we do not use this option, then an output file with name a.out is generated.
  1. Pre-processing
  2. Compilation
  3. Assembly
  4. Linking


  • Removal of Comments.
  • Expansion of Macros.
  • Expansion of the included files.
  • Conditional compilation.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store