Home:ALL Converter>What are the functions of and what is included in the C runtime

What are the functions of and what is included in the C runtime

Ask Time:2014-05-02T19:29:04         Author:Cygnus

Json Formatter

So I have been trying to understand what exactly is the C runtime, and had to go in depth while building my own kernel.

What I've understood is that you don't need a C runtime to build every C program (as is the case of a kernel). Also, the runtime provides an interface between the C program and the kernel. Here are my questions:

  • So what exactly does the runtime do ?

  • Does it only act as this interface (so that if we implement it ourselves, we don't need the runtime), or it has some other functions as well ?

  • Does the runtime link in any files when a program is compiled ?

  • Are common functions like printf or scanf a part of the runtime or the C library ? What kind of functions would be provided by the runtime ?

EDIT: I have referred to What is the C runtime library?, but it doesn't answer my questions. What I have asked is not being addressed there.

Author:Cygnus,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/23427066/what-are-the-functions-of-and-what-is-included-in-the-c-runtime
user1619508 :

I'm going to answer the question from a different perspective, that of a bare-metal embedded system with no operating system. There are two important functions that are performed by the c runtime in this case:\n\n\nUninitialized static variables are given a value of zero (the bss section)\nExplicitly initialized static variables get their intitial value\n\n\nThose are the minimum responsibilities of the C runtime, although there may be other processor-dependent initialization functions. After performing these tasks the runtime just branches to the main function. I haven't checked to see if crt1.o initializes variables but I would assume that it does...my C runtime is just a short assembly program.",
2014-05-02T15:27:33
yy