C中的嵌套函数 [英] Nested function in C
本文介绍了C中的嵌套函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在 C 中使用嵌套函数吗?嵌套函数有什么用?如果它们存在于 C 中,它们的实现是否因编译器而异?
Can we have a nested function in C? What is the use of nested functions? If they exist in C does their implementation differ from compiler to compiler?
推荐答案
你不能在标准 C 的另一个函数中定义一个函数.
You cannot define a function within another function in standard C.
您可以在函数内部声明一个函数,但它不是嵌套函数.
You can declare a function inside of a function, but it's not a nested function.
gcc 有一个允许嵌套函数的语言扩展.它们是非标准的,因此完全依赖于编译器.
gcc has a language extension that allows nested functions. They are nonstandard, and as such are entirely compiler-dependent.
这篇关于C中的嵌套函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文