How a 'c' compiler works ?

Status
Not open for further replies.

agnivesh

Member level 2
Joined
Apr 24, 2004
Messages
45
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
UK
Activity points
549
I want to know, how C compilers work ?

a) what compiler does to a 'C' source code, step by step ?
b) what sort of information the files with .obj, .dll , .h extensions contain ?
c) how we can use assembly code in C and C code in assembly (can we) ?
d) do header files (*.h) contain only declarations of functions and variables or their definitions as well ?
e)By looking at our source code, how compiler finds and links the required code for the used functions, from the library files into our source files or does it link all the library containing all the code for other non-required functions as well, even if we need code for only one funcion from that library ?

Please, suggest me any online resources to understand C compiler working.

thanks in advance
agnivesh
 

a compiler ONLY PRODUCES object code . wheather is a BASIC , C , PASCAL or any other language .
Object code is machine codes without the final LINKING .. it means that some final CODE may be missing to become a full PROGRAM . this code may be in another object code piece . also the right order may not be determined ..from there that the instructions don't have the final address determination .
The linker is the final part that saws all the modules in the right ORDER and assigns the addresses and finaly a STARTING point to become an executable
 

the compiler converts your source code into an object file and then the linker does the job of re-ordering and linking the necessary code to form the executable.
the syntax errors are also checked by the compiler before the conversion.

the header (.h) files contain definition for predefined functions or keywords. it basically defines all the pre-defined functions and operators used in your program. you can also create your own header files and make your own functions and include it in your program. just make sure you save it with a .h extension. if you want to find out what exactly exists in a header file, just open it using any editor. they are present in your INCLUDE directory of your C compiler.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…