Programming Environment: Editor, Compiler, Linker, Debugger, Profiler in C++
When it comes to the implementation of software systems, programming is of course one of the central tasks. the below Figure shows the programming environment as a sequence of work steps:
The programmer is supported by the following tools in each of these steps:
You will only get to know these tools in general here. It is absolutely necessary that you, in parallel to working with this book, have a development programming environment with which you can create your C / C ++ programs. To what development programming environment it is relatively unimportant since we are concerned with our Programs will only move in an area that is different from all development programming environments is supported. All specific details about editor, compiler, linker, For debugger and profiler, please refer to the manuals for your development programming environment!
Editor in Programming environment:
A program is created and saved in a text file like a letter. Of the Program text (source text) is created with a so-called editor3. It can The whole point of this book is not to give you a particular editor with all of its To present possibilities. The editors of most development programming environments are based on the possibilities of modern word processing systems, so that you, if you are familiar with a word processing system, none Have difficulties using the editor in your development programming environment should. In addition to the pure word processing functions, the editor in the Rule functions that provide you with targeted support when creating programs. Kind and However, the scope of these functions also varies from development programming environment to development environment different, so we cannot go into it here. Practice using the functions of your editor in a targeted manner, because the “Manual” aspects of programming are important!
With the editor as a tool, we create our programs, which we save in files lay down. In connection with C programming these are:
Source code files
Header files are files that contain information about data types and structures, interfaces of functions, etc. These are general agreements that are made in different places (i.e. in different Source and header files) are required uniformly and consistently. Header files are not the focus of our interest at the moment. At the latest with the Introducing data structures, however, we will show you the great importance of this Explain files.
The source code files contain the actual program text and are our first priority. You can tell the type (header or source) of a file from the name of the file detect. Header files have the filename extension .h, source code files recognizable by the extension .c in C or .cpp and .cc in C ++.
compiler Programming environment:
A program in a higher programming language is not on a computer immediately executable. It has to be written into machine language by a compiler4 of the carrier system. The compiler translates the source code (the C or CPP files) into the so-called Object code and takes various checks to ensure the correctness of the transferred Source codes before. All violations of the rules of programming language5 will be indicated by targeted error messages indicating the line. Just one A completely error-free program can be translated into object code. Lots of compilers admonish formally correct, but possibly problematic Instructions through warnings. When troubleshooting, you should strictly follow the Proceed in the order in which the compiler reported the errors. Because often takes place the compiler does not find the correct restart point after an error and reports subsequent errors in your program code, which on closer inspection turn out to be even turn out not to exist.
The compiler creates exactly one object file for each source file, whereby only the inner The correctness of the source file is checked. General exams can be found here not yet carried out. The object code generated by the compiler is therefore also not yet executable, because a program usually consists of several Source files whose object files still have to be combined in a suitable way.
linker in Programming environment
The still missing assembly of the individual object files into a finished program the linker takes over 6. The linker takes the outstanding overarching Exams before. This can also reveal a number of errors.
For example, the linker can look at all object files find that it is trying to use a function that is nowhere available. Ultimately, the linker creates the executable program, which also includes other functions or class libraries can be linked. Libraries included compiled functions for which no source code is usually available, and are z. B. made available by the operating system or the C runtime system. You can find many useful, free, or commercial libraries on the Internet that include Can make your programming work a lot easier.
debugger in Programming environment
The Debugger7 is used to test programs. With the debugger, the programs created can be observed during their execution. In addition, you can You can access the running program by manually changing variable values intervene etc. A debugger is not only used to localize programming errors, but also to analyze a program by reproducing the program flow or pronounced for interactive learning of a programming language helpful. You should therefore work your way to operating the debugger of your Development programming environment and not just when you need it for troubleshooting. When troubleshooting your programs, always keep in mind what Brian Kernighan, next to Dennis Ritchie and Ken Thomson one of the fathers of the programming language C, in the quote already mentioned at the beginning, which is freely translated:
Troubleshooting is twice as hard as writing code. So if you can tries to write the code as intelligently as possible, one is in principle unable to find his fault.
Profiler in Programming environment
If you want to analyze and optimize the performance of your programs, you should use a profiler. A profiler monitors your program at runtime and creates so-called runtime profiles, which contain information about the used Computing time and the used memory included. Often can You do not have a program with regard to its running time and its memory optimize consumption. A better time behavior is often bought with a higher one Memory requirements and a lower memory requirement with a longer runtime. You know that from the decision to buy a car. When you transport more you have to accept restrictions on the maximum speed. Conversely, if you want a fast car, you usually have less Room. In extreme cases, you may have to find yourself between a truck and a sports car decide. The analysis of the memory and runtime complexity of programs is part of the professional Software development like analyzing the efficiency of an engine to one professional engine development. An inefficient program is like an engine which converts the supplied energy mainly into waste heat.
Object-Oriented Software Development (OOSD)
write a Program and implementation in c++