Difference atexit() and at_quick_exit()

Difference atexit() and at_quick_exit()

本文关键字:quick exit and atexit Difference at      更新时间:2023-10-16

atexit()at_quick_exit()有什么区别?
我们在 atexit(( 注册的每个函数也必须在 at_quick_exit(( 注册吗?
例如,凤凰-辛格尔顿自定义函数或其他函数。

好吧,从at_quick_exit:

Registers the function pointed to by func to be called on quick program termination (via std::quick_exit). ... The registered functions will not be called on normal program termination. If a function need to be called in that case, std::atexit must be used.

atexit()上注册的函数在exit()调用。向at_quick_exit()注册的函数在quick_exit()上调用。
另一个区别是at_quick_exit()从 C++11 开始可用,而在 C 中不可用。