Use your 1.C language history and features.

Source: Internet
Author: User

What is the development and characteristics of 1.C language? C was born at the same time as the UNIX operating system during the 1969--1973 years; The most creative period is 1972 years. Another big change occurred over 1977-1979 years, when the portability of UNIX systems was proven. In the middle of the latter period, the first widely disseminated description of the language appeared: C programming language, often referred to as 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 was further revised. Until the early 1980, although the compiler had appeared on a variety of machine structures and operating systems, the language was almost particularly closely related to UNIX, and, more recently, its use spread more widely, and today it is almost the most used language in the computer industry. Location Bell Telephone Laboratory company features: C language Features 1. Simple and compact, flexible and convenient C language altogether only 32 keywords, 9 kinds of control statements, program writing freedom, mainly in lowercase letters. It combines the basic structures and statements of high-level languages with the practicality of low-level languages. C language can be like assembly language on Bits, bytes and addresses to operate, and these three are the computer's most basic unit of work. 2. Operators rich in C contain a wide range of operators, with a total of 34 operators. The C language handles parentheses, assignments, coercion type conversions, and so on as operators. So that the operation type of C is extremely rich in expression type diversification, flexible use of various operators can be implemented in other high-level languages difficult to implement operations. 3. Data structures rich in C are: integer type, real type, character type, array type, pointer type, struct type, common body type, etc. Can be used to implement a variety of complex data types of operations. The concept of pointers is introduced to make the program more efficient. In addition, the C language has powerful graphics features and supports a variety of displays and drives. and the computation function, logic judgment function is powerful. 4. C is the distinguishing feature of structured language structured language is the separation of code and data, that is, the various parts of the program are independent of each other except the necessary information exchange. This structured approach makes the program level clear, easy to use, maintain, and debug. C language is provided to the user in the form of functions, these functions can be easily called, and have a variety of loop, conditional statement control program flow, so that the full structure of the procedure. 5. C Grammar restriction is not very strict, the programming freedom is large general high-level language grammar check is strict, can check out almost all grammatical errors. The C language allows program writers to have greater degrees of freedom. 6. C language allows direct access to the physical address, you can directly operate the hardware so that both the high-level language features, but also has a number of low-level language features, can be like assembly language on Bits, bytes and addresses to operate, and these three are the most basic computer work unit, can be used to write system software。 7. C Language Program generates high-quality code, program execution efficiency is generally only less efficient than the assembler generated target code 10へ20%. 8. C Language wide range of application, portability good C language has a prominent advantage is suitable for a variety of operating systems, such as DOS, UNIX, also applicable to a variety of models 2. What are the common low-level and high-level languages? Low-level languages include machine language (a string of code consisting of 0 or 1) and assembly language (replacing commonly used machine code with some tokens). High-level languages include C C + + Java c#c#, vb.net, FoxPro, Delph. These languages conform to the developers ' thinking habits, and they don't require much knowledge of computer hardware. Program development is also possible. 3.C program from writing to compiling to execution? Compile, compile the program to read the source program (character stream), the lexical and grammatical analysis, the high-level language instruction into the functional equivalent of the assembly code, and then by the assembler to machine language, and according to the operating system to the executable file format of the requirements of the chain to be executed program. C Source Program header file--pre-compile processing (CPP)----the compiler itself----optimizer----the assembler----and the linker---executable 1. Compile preprocessing read C source program, in which the pseudo-instructions (in # The beginning of the instruction) and special symbols for processing pseudo-directives mainly include the following four aspects (1) macro definition directives, such as # define Name tokenstring, #undef等. For the previous pseudo-directive, the precompilation is to replace all the name in the program with Tokenstring, but the name as a string constant is not replaced. For the latter, the definition of a macro is canceled so that subsequent occurrences of the string are no longer replaced. (2) Conditional compilation directives, such as #ifdef, #ifndef, #else, #elif, #endif, and so on. The introduction of these pseudo-directives allows programmers to define different macros to determine which code is processed by the compiler. The precompiled program will filter out unnecessary code according to the relevant files (3) header contains directives, such as # include "FileName" or # include such as In a header file, a large number of macros (the most common character constants) are defined with a pseudo-directive # define, along with declarations of various external symbols. The main purpose of the header file is to make certain definitions available to a number of different C source programs. Because in a C source program that needs to use these definitions, you can simply add an # include statement instead of repeating the definitions in this file again. The precompiled program adds all the definitions in the head file to the output file it produces for processing by the compiler. Header files that are included in the C source program can be system-supplied, and these header files are typically placed in the/usr/include directory. In the program # include them to use angle brackets (< >). In addition, developers can also define their own header files, these files are generally in the same directory as the C source program, in this case, in the # include with double quotation marks (""). (4) Special symbols, pre-compiled program can recognize some special symbols. For example, the line identifier that appears in the source program is interpreted as the current row number (decimal number), and file is interpreted as the name of the currently compiled C source program. The precompiled program will replace the strings that appear in the source program with the appropriate values. What the precompiled program accomplishes is basically an "override" of the source program. In this substitution, an output file with no macro definition, no conditional compilation instructions, and no special symbols is generated. The meaning of this file is the same as the source file without preprocessing, but the content is different. Next, the output file will be translated into machine instructions as the output of the compiler. 2. The compilation phase is precompiled in the output file and will only have constants. such as numbers, strings, definitions of variables, and C language keywords, such as main,if,else,for,while,{,}, +,-, *,\, and so on. The pre-compiler works by lexical analysis and parsing, after confirming that all instructions conform to grammatical rules, translate them into equivalent intermediate code representation or assembly code. 3. Optimization stage optimization process is a relatively difficult technology in the compilation system. It concerns not only the compiler technology itself, but also the hardware environment of the machine has a great relationship. Optimization is part of the optimization of the intermediate code. This optimization is not dependent on the specific computer. The other optimization is mainly for the generation of target code. , we put the optimization stage behind the compiler, which is a more general representation. For the former optimization, the main work is to delete the common expressions, loop optimization (out-of-code, strength weakening, transformation loop control conditions, known amount of consolidation, etc.), replication propagation, and deletion of useless assignments, and so on. The latter type of optimization is closely related to the hardware structure of the machine, and the most important consideration is how to make full use of the values of the variables stored in the machine's various hardware registers to reduce the memoryNumber of visits. In addition, how to carry out instructions according to the characteristics of the machine hardware (such as pipelining, RISC, CISC, VLIW, etc.) and some of the instructions to make the target code is relatively short, the efficiency of execution is relatively high, is also an important research topic. The optimized assembly code must be translated into the appropriate machine instructions by the assembler assembly, which may be executed by the machine. 4. The assembler process actually refers to the process of translating assembly language code into a target machine instruction. For each C language source process that is processed by the translation system, it will eventually get the corresponding target file through this processing. A machine language code that is stored in the target file, which is the target equivalent to the source program. The destination file consists of segments. Typically, there are at least two segments in a target file: The code snippet contains the main instructions for the program. The paragraph is generally readable and executable, but is generally not writable. The data segment mainly stores various global variables or static data to be used in the program. General data segments are readable, writable, and executable. There are three main types of target files in the UNIX environment: (1) relocatable files contain code and data that are appropriate for other destination file links to create an executable or shared destination file. (2) Shared destination file This file holds the code and data that are appropriate for linking in both contexts. The first thing the linker can do with other relocatable files and shared target files to create another target file; the second is that the dynamic linker combines it with another executable file and other shared target files to create a process image. (3) executable file It contains a file that can be executed by the operating system to create a process. The assembler is actually generating the first type of target file. For the latter two also need some other processing side can get, this is the work of the link program. 5. The target files generated by the linker by the assembler are not immediately executed, and there may be many unresolved issues. For example, a function in one source file might refer to a symbol defined in another source file (such as a variable or function call), a function in a library file might be called in a program, and so on. All of these problems need to be resolved by the process of the linked program. The main task of the linker is to connect the relevant target files to each other, and the symbols referenced in one file are connected to the definition of the symbol in another file, so that all these target files become a unified whole that can be executed by the operating system. Depending on how the developer assigns the same library function, the link processing can be divided into two types: (1) static links in this way, the code of the function will be copied from its location in the static link library to the final executable program. The code is then loaded into the virtual address space of the process when it is executed. A static link library is actually a collection of target files, each of whichA piece of code that contains one or a set of related functions in the library. (2) dynamic linking in this way, the code of the function is placed in a target file called a dynamic link library or a shared object. What the linker does at this point 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 is executed, the entire contents of the dynamic-link library are mapped to the virtual address space of the corresponding process at run time. The dynamic linker will find the appropriate function code based on the information recorded in the executable program. For function calls in an executable file, you can use either dynamic or static linking methods, respectively. Using dynamic linking can make the final executable shorter and save some memory when the shared object is used by multiple processes because only one copy of the code for this shared object is stored in memory. However, it is not necessarily better to use dynamic links than to use static links. In some cases, dynamic linking can lead to some performance damage

The

uses its own 1.C language history and features.

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.