• 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.
    
  • 相关阅读:
    U盘分区 将一个u盘分为3个区
    InnoDB索引最通俗的解释
    Centos7 安全加固
    final/static
    Java继承,方法重写
    UnrealEngine4血溅效果
    UnrealEngine4第一人称射击游戏之触碰掉血与掉盔甲功能实现
    UnrealEngine4第一人称射击游戏UI
    String字符串
    构造方法
  • 原文地址:https://www.cnblogs.com/Searchor/p/14006969.html
Copyright © 2020-2023  润新知