在C ++中递归到main()中是否合法? [英] Is it legal to recurse into main() in C++?
本文介绍了在C ++中递归到main()中是否合法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我读到C ++标准在 main()
中禁止递归,但是g ++编译了以下代码而不投诉:
I read that the C++ standard forbids recursion in main()
, but g++ compiles the following code without complaint:
int main()
{
main();
}
任何人都可以澄清这一点?
Can anyone clarify this?
推荐答案
根据3.6.1 / 3中的标准,它不是:
According to the standard in 3.6.1/3, it's not :
程序中不能使用
main
(3.2) $ b
的定义是
如果其名称出现在可能评估的表达式中,则使用对象或非重载的
函数。
An object or non-overloaded function is used if its name appears in a potentially-evaluated expression.
这篇关于在C ++中递归到main()中是否合法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文