Multiple File Development in C Flashcards

1
Q

what is a module

A

a source code file is often called a module. Programs are often separated into a number of modules that each contain related code as a way of performing a systematic decomposition of the program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

properties of modules

A

provide a layer of abstraction—the outside
the world knows what a module can do and uses it, but not how the module does it.

The module encapsulates the internal implementation details of the module.

also, provide distinct identifiable locations for specific program functionality, which is useful when there are multiple programmers working on a large project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Steps in the Software Build: Single File

A

C preprocessor: Gets a module ready to be compiled.
Compiler: Compiles modules into assembly code.
Assembler: Translates (or assembles) assembly code output from the compiler into machine code.
Linker: Combines all of the modules of a program and any libraries it uses into a single executable file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

C preprocessor

A

to prepare a module (a .c file) for compilation

Execute preprocessor directives. (ones that start with #)
* Substitute macro names.
* Remove comments

Preprocessor commands/directives modify the .c file before it goes to the compiler.
#include<header.h> command actually inserts the code from header.h into the .c file</header.h>

a defined macro name in the .c file is replaced with the result of its evaluation in the source file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

continued C preprocessor

A

adds some additional information
into the file called line markers, used for a variety of purposes, including producing compiler error messages.

Because of the linemarkers, the output of the C preprocessor is technically no longer a C source file. It is now a .i file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The Compiler

A

performs the translation of a preprocessed .c file (that is, a .i file) into assembly
langauge code.

Assembly language code is a “human readable” version of machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The Assembler

A

translate the resulting assembly
code into machine code.

Result of the assembler process is an object file with a .o extension.

The object file contains (among other things) the compiled and assembled machine code, and a symbol table which records the names of certain variables and their locations within the object file
for use by the linker

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

The Linker

A

combines one or more object files, the standard C library, and any other libraries that might be requested into an executable program

Object files contain placeholder memory addresses for functions and variables that
are used in the module they were compiled from.
linker is to reconcile these temporary memory addresses within individual modules and to combine all of the .o files and libraries together into a single address space where each reference to a function/variable in the various modules refers to the same correct memory address in the module where it is actually defined.
This is called resolving symbols.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly