Fundamental Concepts / Compiling
Subtitles of the Movie
Compiling a C source code module into an executable program is called translating the program. It's a process of translating the source code into machine code and then forming it into a program that can be executed. It happens in eight logical steps. In the first step, source file characters are mapped to the internal representation. Tri-graphs are converted to the single characters they represent. More on tri-graphs coming up later. All backslash characters immediately followed by a new line character are simply removed. This effectively splices the two lines into one, by the way, except for an empty file, all source files must stand with a new line character that is not preceded by a backslash. The source file is separated into tokens. The tokens are separated by white space characters. White space characters are spaces, tabs, new lines and the like. More on this later. Comments are replaced by a single space character. Their pro-processing directives are then executed. Macros are expanded. Any files mentioned on an include statement are inserted and the preceding steps are all executed for those new files. At this point the module being compiled is one huge source file with text from all included files being inserted in line. Any necessary characters conversions are made. Escape sequences are converted to the values of the characters they represent. For example, backslash n character pair is converted into a new line. String literals that are separated by nothing but white space are concatenated together. The source code now consists of a string of tokens. Each token is analyzed and converted into object code. This is the main phase. This is the one we think of when we talk about compiling the source code. The steps that came before were just getting things cleaned up and ready for this step. The resulting objects code is linked with other object code modules to form an executable program. The separate modules can be compiled at different times and even by different compilers. It is the job of the linker to know the format of the object modules and be able to find all the references; find the things they make references to and get them all together. The linker is not part of the compiler really. It's an entirely separate program. Now, it's not necessary that things actually occur in this order but it's required that they appear to occur in this order so as far as you're concerned, this is the order. It is to your advantage to understand the order of things. You can come across something that seems peculiar but knowing what comes first can take the mystery out of it for you.
Tutorial Information
| Course: | Advanced C Programming |
| Author: | Arthur Griffith |
| SKU: | 33965 |
| ISBN: | 1-935320-24-6 |
| Release Date: | 2009-01-30 |
| Duration: | 5.5 hrs / 82 lessons |
| Work Files: |
Yes |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 81,350 Video Tutorials (20,800 free)
- Video Available as Flash or QuickTime
- Over 782 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 