是一个main()需要一个C程序? [英] Is a main() required for a C program?
问题描述
嘛标题说明了一切。是一个的main()
函数的C程序绝对必要的?
Well the title says it all. Is a main()
function absolutely essential for a C program?
我问这个,因为我一直在寻找在Linux内核code,我没有看到一个main()函数。
I am asking this because I was looking at the Linux kernel code, and I didn't see a main() function.
推荐答案
没有,ISO C标准规定,一个主
函数只需要一个托管环境(如为一个与底层OS)。
No, the ISO C standard states that a main
function is only required for a hosted environment (such as one with an underlying OS).
对于像嵌入式系统独立环境(或操作系统本身),它的定义实现。从C99 5.1.2
:
For a freestanding environment like an embedded system (or an operating system itself), it's implementation defined. From C99 5.1.2
:
两个执行环境定义为:独立和主持。在这两种情况下,当一个指定的C函数是由执行环境调用程序启动时发生。
Two execution environments are defined: freestanding and hosted. In both cases, program startup occurs when a designated C function is called by the execution environment.
在独立环境中(其中C程序的执行可能发生没有操作系统的任何利益),名字叫在程序启动时的函数类型是实现定义的。
In a freestanding environment (in which C program execution may take place without any benefit of an operating system), the name and type of the function called at program startup are implementation-defined.
至于Linux本身是如何开始,Linux内核的起点的在start_kernel 不过,对于整个启动过程的一个更全面的了解,你应该开始的这里。
As to how Linux itself starts, the start point for the Linux kernel is start_kernel though, for a more complete picture of the entire boot process, you should start here.
这篇关于是一个main()需要一个C程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!