Pick a Free OS

User login

Navigation

GCC options you should know

8) -ansi : Turns off features of gnu C which are incompatible with ANSI C. This does not put a complete ban on non-ANSI programs. Certain Turbo C features will work. A "-pedantic" option is required to force strict conformance to the ANSI standard.

9) -ffreestanding : Compiles in a freestanding environment. This makes use of the '-fno-builtin' option along with main having no special requirement.

10) -funsigned-char: Declares character S as unsigned. Since character is machine specific, this serves to avoid confusion and common program errors when run on various platforms. For example, suppose a Windows compiler takes a defined character [syntax : char a;] as signed, while the Linux takes it as unsigned. Now, suppose you are having a "if -else" statement -- if (a==0) { /*statements }. Different compilers have different defaults for the signedness of char. Specifying whether a char should be signed or unsigned, removes ambiguity. For example, on the Windows compiler, this statement will be executed considering character as signed while on Linux they are executed considering character as unsigned. This shall result in dubious results because Windows will interpret the object differently. "-fsigned-char" declares a character as signed.

Pre-processor options

1.) -E : Do only preprocessing, no compiling or assembling. Output results to standard output file a.out. Some of the options like -imacros work in tandem with -E and require -E to be present along with it.

2.) -include file : Compiles the file first. The options such as -D, -U are compiled first, regardless of the order in which they are listed. The -include and -imacros get compiled in accordance to the way they appear at the command line.

3.) -imacros : Compiles macros irrespective of the output. The only aim here is to compile the macro and make it available to the program.

4.) -C : Do not discard comments (used with -E option)

5.) -P : Do not generate "#line" commands (used with -E option)

6.) -M : Describes the dependencies of each object file.

Linker options

1.) -laddition : Use library bearing the name addition. Searches a list of standard directories for the library named addition. A "-L /place/where/library/exists" searches the directory specified.

Directory options

1.) -Idirectory : Append a list of directories to the standard directory list.

2.) -I- : Specifying -I after -I- searches for #include directories. If -I- is specified before, it searches for #include "file" and not #include .

Warning messages