Question: The context of a compiler. OR
Question: Cousins of compiler. OR
Question: What does the linker do? What does the loader do? What does the Preprocessor do? Explain their role(s) in compilation process.
Question: Cousins of compiler. OR
Question: What does the linker do? What does the loader do? What does the Preprocessor do? Explain their role(s) in compilation process.
Preprocessor:
Preprocessor produces input to compiler. They may perform the following functions,
- Macro processing: A preprocessor may allow user to define macros that are shorthand for longer constructs.
- File inclusion: A preprocessor may include the header file into the program text.
- Rational preprocessor: Such a preprocessor provides the user with built in macro for construct like while statement or if statement.
- Language extensions: this processors attempt to add capabilities to the language by what amount to built-in macros. Ex: the language equal is a database query language embedded in C. statement beginning with ## are taken by preprocessor to be database access statement unrelated to C and translated into procedure call on routines that perform the database access.
Assembler:
Assembler is a translator which takes the assembly program as an input and generates the machine code as a output. An assembly is a mnemonic version of machine code, in which names are used instead of binary codes for operations.
Linker:
Linker allows us to make a single program from a several files of relocatable machine code. These file may have been the result of several different compilation, and one or more may be library files of routine provided by a system.
Loader:
The process of loading consists of taking relocatable machine code, altering the relocatable address and placing the altered instructions and data in memory at the proper location.