Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between C/C++ Runtime Library and C/C++ Standard Library

Tags:

c++

c

Can you guys tell me the difference between them?

By the way, is there something called C++ library or C library?

like image 223
MainID Avatar asked Jan 08 '09 15:01

MainID


People also ask

What are C runtime libraries?

The C runtime library is a collection of subroutines that are needed to build a program in C. The subroutines can basically be put into 2 categories: C standard library. Compiler-specific auxiliary functions.

What does C runtime mean?

The C runtime Library (CRT) is the part of the C++ Standard Library that incorporates the ISO C standard library. The Visual C++ libraries that implement the CRT support native code development, and both mixed native and managed code. All versions of the CRT support multi-threaded development.

What are standard C libraries defined in C++?

The C standard library provides macros, type definitions and functions for tasks such as string handling, mathematical computations, input/output processing, memory management, and several other operating system services.

Is the C standard library written in C?

In a typical case, the C standard library is written primarily in C, and the C++ standard library primarily in C++. To give some concrete numbers, Microsoft's standard library has ~1050 C and C++ files, and 37 assembly language files.


2 Answers

The C++ Standard Library and C Standard Library are the libraries that the C++ and C Standard define that is provided to C++ and C programs to use. That's a common meaning of those words, i haven't ever seen another definition of it, and C++ itself defines it as this:

The C++ Standard Library provides an extensible framework, and contains components for: language support, diagnostics, general utilities, strings, locales, containers, iterators, algorithms, numerics, and input/output. The language support components are required by certain parts of the C++ language, such as memory allocation (5.3.4, 5.3.5) and exception processing (clause 15).

C++ Runtime Library and C Runtime Library aren't so equally used. Some say a runtime library is the part that a program uses at runtime (like, the code that implements std::type_info or the code supporting signal handlers) as opposed to stuff that they only use at compile time (like macro definitions). Other people say that a runtime library is one that is linked to a program at load time dynamically, as opposed to statically at compile time, though this use is very seldom. shared library or dynamically linked library are better terms for that.

C++ Library and C Library are very broad terms. They just mean that a library is written in C++ and/or C.

The above is not only limited to C++ and/or C. There are python libraries and there is a python Standard Library too.

like image 116
Johannes Schaub - litb Avatar answered Sep 20 '22 22:09

Johannes Schaub - litb


According to https://en.wikibooks.org/wiki/C_Programming/Standard_libraries#Common_support_libraries, there is a very important difference between Standard Library and Runtime Library. While the Standard Library defines functions that are (always) available to the programmer (but not part of the (initial) specification of the programming language, at least in C), the Runtime Library contains functions that are necessary to actually run a program on a given platform (and are platform-specific / vendor-specific).

For example, printf() is part of the C Standard Library, while program startup (which is in many cases invisible to the programmer) is implemented in the Runtime Library. So for example, you could write a C-program which does not use the Standard Library but you always need the Runtime Library because otherwise, your program could not be executed. But to be honest, this would be of little use because a C-program without the Standard Library could not do input/output so it could not tell you something about its impressive results.

What leads to confusion concerning the difference between those two is:

  1. In every case, the Runtime Library is needed/used and in (nearly) all cases, the Standard Library is used. Furthermore, the Standard Library could be dependent on the Runtime Library and is most probably developed by the same vendor. Therefore, the distinction is not clear and in most cases not necessary.
  2. Microsoft has put the C Standard Library and C Runtime Library together and just calls it C Run-Time Library.
like image 30
Binabik Avatar answered Sep 20 '22 22:09

Binabik