How to understand C Run-Time Library (C Runtime Library)

zhaozj2021-02-17  59

Note: The following contents are collected from the posts related to the discussion in CSND, and combined with their own understanding. for reference only.

1) Running time library is C Run-Time Library, is the concept of C instead of C Language: Take this name is because your C program is required to run functions in these libraries.

2) The C language is the so-called "small kernel" language, which is small (not much keyword, program process control, data type, etc.), so after the C language core developed, Dennis Ritchie and Brian Kernighan rewrites 90% of UNIX system functions with C itself and independently independent of the most commonly used parts, forming header files and corresponding library, c run-time library is thus formed.

3) Subsequently, with the popularity of C language, the manufacturer / individual / group of each C compiler follows the old tradition, and there is corresponding Standard Library on different platforms, but most implementations are related to each platform. of. Since the support and understanding of each C compiler has a lot of differences and subtle differences, there is an ANSI C; ANSI C (Subjective intent) Detailed specified specific meaning and compiler implementation requirements for each element of C language. The new function declaration is introduced, and the standard form of STANDARD LIBRARY is established. So the C operation time library is provided by the compiler manufacturer. As for the header files and library functions provided by other vendors / individual / groups, Third Party C Run-Time Libraries should be called.

4) C Run-Time Library contains initialization code, as well as error handling code (for example, Divide By Zero Process). The program you write can do not have a Math library. The program is still running, but it cannot handle complex mathematical operations, but if there is no C run-time library, Main () will not be called, and exit () cannot be responded. Because C Run-Time Library contains the most basic and most common functions of the C program run.

5) In the C world, there is another concept: Standard C Library, which includes the C Run-Time Library and STL mentioned above. The reason why C Run-Time Library is included, C is a super-collection, no reason to re-come back to C Run-Time Library. VC For C STANDARD C library mainly includes: libcp.lib, libcpmt.lib and MSVCPRT .Lib

6) In the Windows environment, the C Run-Time Library provided by VC is divided into dynamic runtime libraries and static runtime libraries. The dynamic runtime library is mainly the DLL library file msvcrt.dll (or msvcrtd.dll for debug build), the corresponding import library file is the main m m 对 (Release version) The file is: libc.lib (Single Thread Static Library, Retail Version) libcmt.lib (Multithread Static Library, Retail Version)

Msvcrt.dll offers thousands of C functions, even in MSVCRT.DLL even like Printf. In fact, when your program runs, a large part of time runs in these runs. When your program (Release version) is compiled, the VC will automatically automatically turn the corresponding runtime library files (libc.lib, libcmt.lib or import library msvcrt.lib, or import library msvcrt.lib, according to your compilation option (single thread, multi-thread or DLL) Link. Which C Run-Time Library links into your program depends on Compile options: / md, / ml, / mt, / ld (use run-time library) You can set which C Run- time library linked into your program: To find these options in the development environment, click Settings on the Project menu Then click the C / C tab, and click Code Generation in the Category box See the Use Run-Time Library drop-.. Down Box.

From the program portability, if the two functions can complete a function, the time-run time library function is good because the manufacturer of each C compiler provides a unified support for standard C Run-Time Library.

转载请注明原文地址:https://www.9cbs.com/read-29828.html

New Post(0)