Steps taken by a compiler to execute a C program

//steps taken by a compiler to execute a C program
/*  1. pre processing: i) comments removal
                       ii) macros expansion
                       iii) #files inclusion
                       iv) conditional compilation
    2. compilation: converts to assembly level instructions
    3. assembling: converts to machine level instructions
    4. linking: linker combine all machine level instructions
                to create an executable file that is .exe file*/

//to understand better how compiler works follow the below step
/* A) execute "gcc -Wall -save-temps file_name.c" on vs code terminal
    u will get 4 extra files in explorer this files will show u how compiler works
        1. file_name.i : pre processed output saves in this file
        2. file_name.s : (after compilation of .i file) assembly level instructions of .i file
                        will saves here
        3. file_name.o : machine level instructions of file_name.s file content
        4. file_name.exe : linker combines all .o files and make executable file that is .exe file
        */

// Like this the compiler works or execute the C program

Comments

Popular posts from this blog

Tokens in C

Variables and Data Types in C