GCC (GNU Compiler Collection) is a compiler primarily for C. It can also compile C++ programs, but we generally prefer using G++ for this purpose. Both share a common origin, and thus share common flags.

Flags

  • No flags at all will compile to an executable called a.out.
  • -E stops the compiler at the preprocessor stage.
  • -S stops the compiler before the assembler (i.e., gets an output in ASM).
  • -C will compile without using the linker.
  • -o will allow us to specify the output executable file name.
  • -Wall will enable compiler warnings.
  • -save-temps will output all intermediate files (preprocessor, assembly, executable).