zoukankan      html  css  js  c++  java
  • crt

    https://stackoverflow.com/questions/2766233/what-is-the-c-runtime-library

    I just asked this myself and was hurting my brain for some hours.Still did not find anything that really makes a point.
    Everybody that does write something to a topic is not able to actually "teach".
    If you want to teach someone, take the most basic language a person understands, 
    so he does not need to care about other topics when handling a topic.
    So I came to a conclusion for myself that seems to fit well in all this chaos.
    
    In the programming language C, every program starts with the main() function.
    Other languages might define other functions where the program starts.
    But a processor does not know the main().
    A processor knows only predefined commands, represented by combinations of 0 and 1.
    
    In microprocessor programming, not having an underlying operating system (Microsoft Windows, Linux, MacOS,..),
    you need to tell the processor explicitly where to start by setting the ProgramCounter (PC) that iterates 
    and jumps (loops, function calls) within the commands known to the processor.
    You need to know how big the RAM is,
    you need to set the position of the program stack (local variables),
    as well as the position of the heap (dynamic variables)
    and the location of global variables (I guess it was called SSA?) within the RAM.
    A single processor can only execute one program at a time.
    
    That's where the operating system comes in.
    The operating system itself is a program that runs on the processor.
    A program that allows the execution of custom code.
    Runs multiple programs at a time by switching between the execution codes of the programs (which are loaded into the RAM).
    But the operating system IS A PROGRAM, each program is written differently.
    Simply putting the code of your custom program into RAM will not run it, the operating system does not know it.
    You need to call functions on the operating system that registers your program,
    tell the operating system how much memory the program needs,
    where the entry point into the program is located (the main() function in case of C).
    
    And this is what I guess is located within the Runtime Library,
    and explains why you need a special library for each operating system,
    cause these are just programs themselves and have different functions to do these things.
    
    This also explains why it is NOT dynamically linked at runtime as .dll files are, even if it is called a RUNTIME Library.
    The Runtime Library needs to be linked statically, because it is needed at startup of your program.
    The Runtime Library injects/connects your custom program into/to another program (the operating system) at RUNTIME.
    This really causes some brain f...
    
    Conclusion:
    RUNTIME Library is a fail in naming. There might not have been a .dll (linking at runtime)
    in the early times and the issue of understanding the difference simply did not exist.
    But even if this is true, the name is badly chosen.
    Better names for the Runtime Library could be: 
    StartupLibrary/OSEntryLibrary/SystemConnectLibrary/OSConnectLibrary
    
    Hope I got it right, up for correction/expansion. cheers.
    
  • 相关阅读:
    favicon.ico请求处理
    Node.js学习(Node.js基础)
    实现主机访问虚拟机网页的方法总结
    有向/无向图中搜环
    后缀自动机
    莫队算法
    A* 算法求第k短路径
    次小生成树算法
    AC自动机详解
    Link-Cut-Tree详解
  • 原文地址:https://www.cnblogs.com/Searchor/p/14006969.html
Copyright © 2011-2022 走看看