gpt4 book ai didi

c - 在 C 中,缺少 "Main process ends"到 "call any functions registered with atexit"之间的链接

转载 作者:太空宇宙 更新时间:2023-11-04 00:42:51 25 4
gpt4 key购买 nike

在 C 语言中,当主进程结束时——它如何知道调用任何用 atexit() 注册的函数?

我理解 atexit() 是如何工作的,但我不明白“主进程结束”和“调用任何用 atexit() 注册的函数”之间的通信我有点多余。

谢谢!

最佳答案

在 C 语言中,main() 函数实际上是由运行时内置的其他函数调用的。此函数在 main() 函数结束后,还做了一些清理工作。其中之一是调用任何已在 atexit() 中注册的函数。这个函数实际上存储了某种函数指针的静态列表,它将在 main() 之后由运行时调用。

关于c - 在 C 中,缺少 "Main process ends"到 "call any functions registered with atexit"之间的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1799306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com