开发者

In what languages are the C and C++ standard libraries written? Where is their source code?

I always wonder what language was the C/C++ runtime and standard library written in. At first I thought it is a casual C/C++ language, but to be able to talks with the machine I doubt C/C+开发者_如何学JAVA+ is enough. Therefore, I think it may be assembly language instead. If it is either C/C++ or asm language, then why don't I really see source codes flying around? or maybe I'm lacking in searching skill...


They are typically written in their host language, interoperating with the operating system API to obtain things that can't be obtained natively. Many features are written in pure language- for example, the containers & algorithms section of the C++ Standard library pretty much has to be written in C++. In fact, nearly the entire C++ Standard library has to be written in C++, because it's templated. I don't know why you haven't found any source- the Microsoft CRT source is available to any dev, I think, I've certainly seen questions on here posting the CRT source, and the GNU libc++ is open source, I'm pretty sure.


All the run-time and standard libraries are written in C/C++. Most vendors ship the source code.


They are usually written in C with some assembly mixed in. Visual Studio ships with big chunks of source code for CRT (C RunTime) if not all of it. Linux glibc is obviously open source: http://ftp.gnu.org/gnu/glibc/


Most of the runtime is written in C or C++ but there is an important exception and that is the code that calls into the kernel. Onmost operating systems this is done by generating a Software Interrupt using a special instruction (SWI or SVC) on arm. There is no equivalent for this in C or C++ and therefore assembler will be used. Assembler is also typically used to implement highly optimized memcpy, memmove, memcmp and other similar functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜