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

So, I'm trying to understand what the C runtime environment is, and I had to go deeper when creating my own kernel.

I realized that you do not need the C runtime to create each C program (as is the case with the kernel). In addition, the runtime provides an interface between the C program and the kernel. Here are my questions:

  • So what does the runtime do?

  • Does it act only like this interface (so if we implement it ourselves, we don’t need a runtime), or does it have other functions?

  • Is the runtime bound in any files when compiling the program?

  • Are common type functions printfor scanfpart of a C runtime or library? What features will the runtime provide?

EDIT: I mentioned What is the C Runtime Library? but she does not answer my questions. What I requested is not considered there.

+4
source share
2 answers

I am going to answer the question from a different perspective: an embedded system without iron without an operating system. In this case, two important functions are performed:

  • Uninitialized static variables are set to 0 (section bss)

  • Explicitly initialized static variables get their intuitive meaning

C runtime, , . main. , crt1.o , , ... C - .

+4

, :

, printf scanf C? ?

, : " " " " (, , ). , .

, -, " " C, " " (, GCC crt1.o). .

?

API ( , ), ( _start Linux) , ,

  • main, C ( argc argv);
  • getenv;
  • main exit ;
  • , atexit , main ;
  • malloc;
  • stdin, stdout, stderr;
  • , libc -l , .

( , , ), ?

. , , C , C . . MS-DOS, , " DOS-, CPU API DOS .

?

(duh), . , : , , DLL, . , : , , .

+3

Source: https://habr.com/ru/post/1538988/


All Articles