D退出声明 [英] D exit statement
问题描述
D是否具有退出语句,类似于java,python,c/c ++中的语句.哪一个(令人震惊的)退出程序执行?类似于exit();
Does D have an exit statement, similar to the one in java, python, c/c++. Which will (big shocker) exit execution of the program? Something like exit();
推荐答案
如果要exit
,请使用C的exit
函数.
If you want exit
, then use C's exit
function.
import core.stdc.stdlib;
void main()
{
exit(-1);
}
我不太确定那会如何影响D运行时,什么都不会.可能是东西没有像您通常想要的那样被清理干净,或者可能就好了.我一般不建议使用它,因为通常有更好的方法来处理退出程序.但是C函数的声明是在druntime中进行的,因此如果需要,可以轻松使用它.
I'm not quite sure how that affects the D runtime and whatnot though. It might be that stuff doesn't get cleaned up like you'd normally want, or it might be just fine. I wouldn't really advise using it in general though, since there are usually better ways to handle exiting a program. But the declaration for the C function is in druntime, so it's easy to use it if you want it.
这篇关于D退出声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!