Book contents
- Frontmatter
- Contents
- Acknowledgments
- Dedication
- 1 Introduction
- 2 From Source File to Executable File
- 3 Variables and Objects; Pointers and Addresses
- 4 Dynamic Allocation and Deallocation of Memory
- 5 Functions and Function Calls
- 6 One-Dimensional Arrays and Strings
- 7 Multi-Dimensional Arrays
- 8 Classes and Objects
- 9 Linked Data Structures
- 10 Memory Leaks and Their Debugging
- 11 Programs in Execution: Processes and Threads
- A Hanoi Towers Puzzle
- B Tracing Objects in C++
- C Tracing Objects and Memory in C++
- D Thread-Safe and Process - Safe Reporting and Logging Functions
- Glossary
- Index
2 - From Source File to Executable File
Published online by Cambridge University Press: 13 January 2010
- Frontmatter
- Contents
- Acknowledgments
- Dedication
- 1 Introduction
- 2 From Source File to Executable File
- 3 Variables and Objects; Pointers and Addresses
- 4 Dynamic Allocation and Deallocation of Memory
- 5 Functions and Function Calls
- 6 One-Dimensional Arrays and Strings
- 7 Multi-Dimensional Arrays
- 8 Classes and Objects
- 9 Linked Data Structures
- 10 Memory Leaks and Their Debugging
- 11 Programs in Execution: Processes and Threads
- A Hanoi Towers Puzzle
- B Tracing Objects in C++
- C Tracing Objects and Memory in C++
- D Thread-Safe and Process - Safe Reporting and Logging Functions
- Glossary
- Index
Summary
Transformation of a source file to a load (executable) module. Why we can and do discuss source programs and their behavior as if they were executing somewhere in memory in their source form. Concepts of static memory allocation, dynamic memory allocation, program address space, and program system stack.
It is useful and practical to discuss the behavior (often referred to as the semantics) of a computer program written in a high-level language like C or C++ as if it were executing in computer memory in its source form. For instance, the semantics of the statement x = x+1 might be described as “the value of the variable x is incremented by 1”, yet nothing could be farther from the truth because the program in its source form is a simple ASCII text file sitting quietly somewhere on a disk doing nothing. On the other hand, speaking conceptually, this is exactly what happens to the variable x when the program executes - although, to confuse matters even more, there is no variable x to speak of when the program is running. In order to understand all of this, we must discuss the process of compilation, linking, loading, and execution of programs. Most of the facts discussed in this chapter can be found in various books and texts dealing with compilation and compilers, operating systems, and computer architecture.
Both C and C++ belong to a family of high-level symbolic languages, meaning that certain entities in such programs can be referenced by their names (symbols).
- Type
- Chapter
- Information
- Memory as a Programming Concept in C and C++ , pp. 7 - 20Publisher: Cambridge University PressPrint publication year: 2003