·  MinGW – Parameters – Compiler

 

- Info:

  - This tutorial show gcc command line options which define type of output which should be produced. 

  - This tutorial is based on: http://gcc.gnu.org/onlinedocs/gcc/Overall-Options.html#Overall-Options

 

- -o:

  - Defines name of output file(s):

    gcc    Test.c -o myprog

    gcc -S Test.c -o myprog.assembly

  - This parameter must be followed by the name of output file to be created.

  - If given file name has no extension, default extension is given depending on the type of output file: .exe, .s or .o.

  - If omitted, and output file(s):

    - is executable, a.exe is created.

    - are assembler files, they will have the same name as source files but with extension .s.

    - are object files (Machine Code), they will have the same name as source files but with extension .o.

 

- -x:

  - Specifies which compiler to use for following sources:

    gcc -xc Test1.myc Test2 -xcpp Test.mycpp -xnone Test.c

  - This parameter applies to all following input files until the next -x option.

  - If omitted files are compiled based on their extensions.

 

- -E:

  - Stop after preprocessing stage and print results on screen:

    gcc -E Test.c

 

- -S:

  - Compile source files but do not Assemble them:

    gcc -s Test1.c Test2.c

  - Compile means to transform Source Code into Assembly Code.

  - Assemble means to transform Assembly Code into Binary Machine Code.

  - Each listed file is transformed into text file with Assembly Code and extension .s.

 

- -c:

  - Compile and Assemble source files but do not link them:

    gcc -c Test1.c Test2.c

  - Compile means to transform Source Code into Assembly Code.

  - Assemble means to transform Assembly Code into Binary Machine Code.

  - Each listed file is transformed into binary file with object code and extension .o.

 

- -v:

  - Print commands executed by compilation process and version of compiler and preprocessor:

    gcc -v Test.c

 

- -I:

  - Adds directory to the head of the list of directories to be searched for header files:

    gcc -ID:\Temp -I"C:\My Heders" Test.c

  - If more than one -I option is used, directories are scanned left-to-right followed by standard system directories.;

 

- -iqoute:

  - Adds directory to the head of the list of directories to be searched for header files included like #include "stdio.h":

    gcc -iqouteD:\Temp Test.c

  - These directories are not searched for header files included like #include <stdio.h>.

  - If more than one -I option is used, directories are scanned left-to-right followed by standard system directories.

 

- -ansi:

  - In C mode, this is equivalent to -std=c89 and in C++ mode to -std=c++98:

    gcc -ansi -pedantic Test.c

 

- -std=:

  - Insturcts compiler which standard to use:

    gcc -std=c89 -pedantic Test.c

  - Deviations from specified standard will be ignored unless -pedantic is also used.

 

- -pedantic=:

  - Instucts compiler to report all deviations from specified language standard:

    gcc -std=c89 -pedantic Test.c