1. C Language History and features ., 1. C Language

Source: Internet
Author: User

1. C Language History and features ., 1. C Language
1. What are the development and features of C language? C was born along with Unix operating systems in-; the most creative period was. Another major change occurred between 1977 and 1979, when the portability of Unix systems was proven. In the middle of the next period, the first widely-spread description of this language emerged: the C programming language, often referred to as a White Paper or K & R [Kernighan 78]. Finally, in the middle of the 1980 s, it was formally standardized by the ANSI X3J11 Committee and further modified. Until the early 1980 s, although the compiler had appeared on multiple machine structures and operating systems, the language was almost closely related to Unix; more recently, it was widely used, and today it is almost the most widely used language in the computer industry. location Bell Telephone lab company features: C Language Features 1. concise, compact, flexible, and convenient the C language has only 32 keywords and 9 control statements. The program is free to write and is mainly represented by lowercase letters. It combines the basic structure and statements of advanced languages with the practicability of low-level languages. The C language can perform operations like the assembly language on the position, byte, and address. These three are the most basic work units of the computer. 2. Rich operators C operators include a wide range of 34 operators. The C language treats parentheses, assignments, and forced type conversion as operators. Thus, C's operation types are extremely rich and diverse expression types, and various operators can be flexibly used to achieve computation that is difficult to implement in other advanced languages. 3. Rich data structures C's data types include integer, real, String, array, pointer, struct, and shared body. It can be used to perform operations on various complex data types. The pointer concept is introduced to improve program efficiency. In addition, the C language has powerful graphics Functions and supports a variety of displays and drives. The computing and logic judgment functions are powerful. 4. C is a distinctive feature of structured language. It separates code and data, that is, each part of the program is independent of each other except for necessary information exchange. This structured method makes the program layers clear and easy to use, maintain, and debug. The C language is provided to users in the form of functions. These functions can be conveniently called and have multiple loops and conditional statements to control the program flow, so that the program is fully structured. 5. The C syntax is not very strict, and the degree of freedom of programming is large. Generally, the advanced language syntax check is strict, and almost all syntax errors can be checked. C allows programmers to have greater degrees of freedom. 6. the C language allows direct access to the physical address and can directly operate on the hardware. Therefore, the C language provides both advanced language functions and many low-level language functions, operations can be performed on counterpoint, byte, and address like assembly languages. These three are the most basic work units of computers and can be used to write system software. 7. The quality of C language code generation is high, and the program execution efficiency is generally 10-20% less efficient than the target code generated by the assembler. 8. C language has a wide range of applications and is portable. C language has a prominent advantage that it is suitable for a variety of operating systems, such as DOS and UNIX, and also for a variety of models 2. what are common low-level and advanced languages? Low-level languages include machine language (a string of code consisting of 0 or 1) and Assembly Language (replace common machine code with some tokens ). Advanced languages include c ++ java c # C #, vb.net, foxpro, and delph. These languages conform to developers' habits of thinking, and do not need to have too much knowledge about multi-computer hardware. You can also develop programs. 3. How does c program compile, compile, and execute? Compile and compile the program to read the source program (ghost stream), analyze the lexical and syntax, convert advanced language commands into functional equivalent assembly code, and then convert the assembly program into machine language, and generate executable programs based on the requirements of the operating system for the executable file format. C source program header file --> pre-compiled processing (cpp) --> compiled program itself --> Optimized Program --> assembler --> linked program --> Executable File 1. compile the pre-processing to read the c source program, and process the pseudo commands (commands starting with #) and special symbols. The pseudo commands mainly include the following four aspects: (1) macro definition commands, for example, # define Name TokenString, # undef, etc. For the previous pseudo command, all the names in the program must be replaced by TokenString, but the Name as a String constant is not replaced. For the latter, the definition of a macro will be canceled, so that the appearance of the string will not be replaced in the future. (2) Conditional compilation commands, such as # ifdef, # ifndef, # else, # elif, # endif, and so on. The introduction of these pseudo commands allows programmers to define different macros to determine which code the program will process. The pre-compiled program filters out unnecessary code based on the relevant files (3) header file containing commands, such as # include "FileName" or # include . In header files, a large number of macros (the most common is a character constant) are defined using a pseudo command # define, which also contains declarations of various external symbols. The purpose of using header files is to make some definitions available for multiple different C source programs. In the C source program that needs to use these definitions, you only need to add a # include statement, instead of repeating these definitions in this file. The precompiled program adds all the definitions in the header file to the output file generated by the precompiled program for the Compilation Program to process it. Header files contained in the c source program can be provided by the system. These header files are generally stored in the/usr/include directory. # Include them in the program using angle brackets (<> ). In addition, developers can also define their own header files. These files are generally placed in the same directory as the c source program. In this case, double quotation marks ("") are used in # include (""). (4) special symbols. Pre-compiled programs can recognize some special symbols. For example, the LINE mark in the source program will be interpreted as the current LINE number (in decimal number), and the FILE will be interpreted as the name of the currently compiled C source program. The pre-compiled program replaces these strings with appropriate values in the source program. The pre-compiled program basically replaces the source program. After this replacement, an output file without macro definition, Conditional compilation instructions, and special symbols is generated. The meaning of this file is the same as that of the source file without preprocessing, but the content is different. Next, the output file will be translated into machine commands as the output of the Compilation Program. 2. Only constants are included in the output file after pre-compilation in the compilation phase. Such as numbers, strings, variable definitions, and keywords in C language, such as main, if, else, for, while, {,}, +,-, *, \, and so on. The pre-compiled program performs lexical analysis and syntax analysis to translate all commands into equivalent intermediate code representation or assembly code after confirming that they comply with the syntax rules. 3. optimization processing in the optimization stage is a difficult technology in the compilation system. It involves not only the compilation technology itself, but also the hardware environment of the machine. The optimization part is the optimization of the intermediate code. This optimization does not depend on a specific computer. Another optimization is mainly for generating the target code. We put the optimization stage behind the Compilation Program, which is a general representation. For the previous optimization, the main work is to delete public expressions, loop optimization (out-of-code optimization, weak strength, changing cycle control conditions, merging of known quantities, etc.), and re-write propagation, and the deletion of useless values. The Optimization of the latter type is closely related to the hardware structure of the machine. The main consideration is how to make full use of the values of relevant variables stored in each hardware register of the machine, to reduce the memory access times. In addition, how to make some adjustments to commands based on the features of machine hardware execution commands (such as pipelines, Proteus, CISC, and VLIW) to make the target code relatively short and the execution efficiency relatively high, it is also an important research topic. The compiled code after optimization must be compiled by the assembler and converted into corresponding machine commands, which may be executed by machines. 4. assembly process refers to the process of translating assembly language code into target machine commands. For each C language source program processed by the translation system, the corresponding target file will be obtained after this processing. What is stored in the target file is the machine language code equivalent to the source program. The target file consists of segments. Generally, a target file contains at least two segments: the code segment contains instructions of the program. This section is generally readable and executable, but generally cannot be written. The data segment mainly stores various global variables or static data used in the program. Generally, data segments are readable, writable, and executable. There are three main types of target files in UNIX: (1) relocated files include code and data suitable for creating an executable or shared target file using links to other target files. (2) shared target files store the code and data suitable for linking in two contexts. First, the linking program can process it with other relocated files and shared target files to create another target file; the second is that the dynamic link Program combines it with another executable file and other shared target files to create a process image. (3) an executable file contains a file that can be executed by a process created by the operating system. The assembler generates the first type of target file. For the last two methods, some other processing is required. This is the work of The Link program. 5. the target file generated by the assembler in the linked program cannot be executed immediately. There may be many unsolved problems. For example, a function in a source file may reference a symbol (such as a variable or function call) defined in another source file, or call a function in a library file in a program. All these problems must be handled by the linked program. The main task of linking a program is to connect the target file to each other, or connect the symbols referenced in one file with the definition of the symbol in another file, this makes all these target files a unified whole that can be loaded and executed by the operating system. Based on the connection methods specified by developers for functions of the same library, link processing can be divided into two types: (1) Static links in this connection mode, the code of the function will be copied from the static link library where it is located to the final executable program. In this way, when the program is executed, the code will be loaded into the virtual address space of the process. The static Link Library is actually a collection of target files. Each file contains the code of one or more related functions in the library. (2) In this way, the code of a function is put in a target file called a dynamic link library or shared object. What the linked program does at this time is to record the name of the shared object and a small amount of other registration information in the final executable program. When the executable file is executed, all content of the dynamic link library will be mapped to the virtual address space of the corresponding process at runtime. The dynamic link program finds the corresponding function code based on the information recorded in the executable program. For function calls in executable files, dynamic or static links can be used respectively. Dynamic Links can make the final executable files relatively short, and save some memory when the shared object is used by multiple processes, because only one copy of the shared object code needs to be saved in the memory. However, dynamic links are superior to static links. In some cases, dynamic links may cause performance damage.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.