Compiler Option
-I
Alphabet I
Used to specify the location where to search for the header files
-l
Alphabet L
Used to specify the library to be linked with the code.
-Wall
Display all the warnings in the program
To enable the Debugging symbol table
gcc -g hello.c –o hello
To display all the warnings in the program
gcc –Wall hello.c
To make all the warnings as error
gcc –Werror –Wall hello.c
To use the compile time macors using –D option
gcc –DMY_MACRO main.c –o main
To interpret char as unsigned char
gcc –funsigned-char main.c –o main
To interpret char as signed char
gcc –fsigned-char main.c –o main
Only compile the code, instead of linking
gcc –C main.c
To produce the assembly code of program
gcc -S main.c > main.s
To generate the optimized code
gcc -O main.c –o main.o
To save all the intermediate files. For example, if you want to see the file after pre-processing, you have to see filename.i file.
Gcc –save-temps macro.c –o macro
Math library
If you are getting error during the inclusion of math library, you have to include that during the compilation.
gcc test.c –lm (or) gcc test.c -lmath
option –lm will link the math library by the linker.
Segmentation fault
It is raised, when there is uninitialized memory.
In file operation, if you are closing the file, without opening the file, you will get segmentation fault.
In scanf, if you are not using the ‘&’ operator for the address of the variable, segmentation fault occurs.
In Scanf, if you are giving ‘\n’ inside the double quotes, you will get the segmentation fault.
No comments:
Post a Comment