Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What language are the C and C++ standard libraries written in?

Tags:

C and C++ by themselves can't actually do anything, they need the libraries to work. So how were the libraries created? Assembly language?

like image 450
alecwhardy Avatar asked Jul 08 '11 05:07

alecwhardy


People also ask

What is the C language and standard C library?

The C standard library or libc is the standard library for the C programming language, as specified in the ISO C standard. Starting from the original ANSI C standard, it was developed at the same time as the C library POSIX specification, which is a superset of it.

What programming language is C written in?

It was based on CPL (Combined Programming Language), which had been first condensed into the B programming language—a stripped-down computer programming language—created in 1969–70 by Ken Thompson, an American computer scientist and a colleague of Ritchie.

Where are standard C libraries defined in C?

The function is defined in the math. h header file.


1 Answers

C and C++ libraries are almost universally written in C and C++, as are C and C++ compilers. In fact, many compilers are even used to compile themselves!

How is this possible? Well, obviously the first C compiler couldn't have been initially developed in C. However, once a C compiler exists, then it can be used to compile another compiler. And as a compiler is being developed, so is the source code. It's possible to develop both side-by-side. Since most compilers are improvements on their predecessors, they are often used to compile better versions of themselves!

However, with respect to the library, that's easy: C can actually do something. While some lower-level routines may be written in assembler, the vast majority can be written in C or C++.

like image 61
Jonathan Wood Avatar answered Sep 23 '22 17:09

Jonathan Wood